mysql在linux上出现Access denied for user 'root'@'localhost' (using password: NO)解决方案

1.查看当前密码:sudo cat /root/.mysql_secret

2.登陆:mysql -uroot -p 提示密码时输入上条命令cat出来的密码,成功登陆mysql

3.通过mysql命令修改密码:alter user 'root'@'localhost' identified by ’登陆进来的密码’;

4.update mysql.user set authentication_string=password('您的密码') where user='root' and Host='localhost';

5.写入:flush privileges;

6.退出quit
 

猜你喜欢

转载自blog.csdn.net/laikaikai/article/details/86618579