linux中忘记了mysql的root用户的密码怎么办?

1.vim /etc/my.cnf
skip-grant-tables  #取消此行的注释

2.重启mysql
systemctl restart mysqld

3.mysql 登陆mysql
mysql> use mysql;
mysql> UPDATE user SET Password = password ( '123456' ) WHERE User = 'root' ;
mysql> flush privileges ;
mysql> quit

4.恢复配置文件my.cnf
vim /etc/my.cnf
[mysqld]
skip-grant-tables ##去掉此行,继续校验权限表,

5.重启mysql
systemctl restart mysqld

posted @ 2020-01-14 17:10  IT蓝月  阅读(799)  评论(0编辑  收藏  举报
Live2D