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

1. 中止mysql:mysql

service mysqld stop

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

3. 启动mysql:ui

service mysqld start

4. 进入mysql:spa

mysql -u root

5. 选取mysql表:rest

use mysql;

6. 重置root密码:code

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

7. 刷新权限表:blog

FLUSH PRIVILEGES;

8. 退出mysql登陆:ip

quit;

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

10.重启mysqld:it

service mysqld restart

11. 用刚刚设置好的密码登陆mysql便可:

mysql -u root -p
相关文章
相关标签/搜索