您的位置:首页 > 运维架构 > Linux

CentOS6.8中MySQL忘记密码与字符设置处理

2017-05-17 00:00 537 查看
摘要: http://ericchunli.iteye.com/blog/2364614
1.导入脚本:source /root/store.sql

2.查看数据库:show databases

3.使用数据库:use store

4.查看表:show tables

5.描述表:describe t_order_info

6.清空表:truncate table t_order_info

7.给表加主键:alter table t_order_info add primary key(orderId)

8.设置mysql中的字符集

show variables like "%character%";

#找到mysql的配置文件,在mysqld下面加上

character-set-server=utf8

collation-server=utf8_general_ci

# 在client下面加上

default-character-set=utf8即可设置mysql中的字符集

9.MySQL忘记密码处理方案

# 找到mysql的配置文件直接编辑

vim /etc/my.cnf 【有些变态的刚装好没有这个文件,只有一个my.cnf.bak的文件,复制改个名即可】

# 在 [mysqld] 中加上一行跳过权限限制

skip-grant-tables

# 保存退出 重启mysql服务

service mysqld restart

# 用户登录

mysql -uroot -p (直接点击回车,密码为空)

# 选择数据库

use mysql;

# 进行重置密码修改

update user set authentication_string=password('new password') where user='root';

# 刷新权限

flush privileges;

# 退出mysql

quit;

# 将配置文件my.cnf中的skip-grant-tables删除后重启mysql

service mysqld restart

# 如果出现

ERROR 1819 (HY000): Your password does not satisfy the current policy requirements # 执行两个参数来把mysql默认的密码强度的取消或者当然把密码复杂度提高

set global validate_password_policy=0;

set global validate_password_mixed_case_count=2;

# SET PASSWORD = PASSWORD('root');

Linux重启MySQL方法:
1、使用 service 启动:service mysqld start

2、使用 mysqld 脚本启动:/etc/inint.d/mysqld start

3、使用 safe_mysqld 启动:safe_mysqld&
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  MySQL