CentOs中mysql服务器重置root密码方法

1. 停止mysql:

service mysqld stop

2. 编辑/etc/my.cnf,在[mysqld]这行后面加上skip-grant-tables ,并保存

3. 启动mysql:

service mysqld start

4. 进入mysql:

mysql -u root

5. 选取mysql表:

use mysql;

6. 重置root密码:

update user set Password=PASSWORD('targetpassword') where USER='root';

7. 刷新权限表:

FLUSH PRIVILEGES;

8. 退出mysql登录:

quit;

9. 重新编辑/etc/my.cnf,去除开始添加的一行设置skip-grant-tables ,并保存

10.重启mysqld:

service mysqld restart

11. 用刚刚设置好的密码登录mysql即可:

mysql -u root -p

 

 

  

 

posted @ 2017-12-22 16:35  fullStack-yang  阅读(138)  评论(0编辑  收藏  举报