关闭mysql服务
service mysqld stop
![](https://img.haomeiwen.com/i3906923/08e741a877073a67.jpg)
使用skip-grant-tables
参数启动mysql服务
mysqld --user=mysql --skip-grant-tables &
![](https://img.haomeiwen.com/i3906923/a44f4d46398c7845.jpg)
为root用户重置密码
输入mysql
进入mysql命令行界面:
![](https://img.haomeiwen.com/i3906923/ea612504eff5686a.jpg)
重置密码:
update mysql.user set authentication_string = password('new_password') where user = 'root';
flush privileges;
注意:
new_password
代表root用户的新密码, 需要根据自己实际情况来替换
杀死mysql服务进程
kill -9 `pidof mysqld`
开启mysql服务并用新密码登录mysql
开启mysql服务:
service mysqld start
![](https://img.haomeiwen.com/i3906923/6be4c9e7bc9c2132.jpg)
![](https://img.haomeiwen.com/i3906923/45165c9c80fb3e6d.jpg)
网友评论