MySQL登录错误提示:ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

1,停止mysql服务

systemctl stop mysqld.service

2,修改配置文件无密码登录

vi /etc/my.cnf
在最尾部加上

skip-grant-tables
保存

3,启动mysql

systemctl start mysqld.service

4,登录musql
mysql -u root
此处注意不要加-p


5,修改密码,mysql5.7用此语法

use mysql ;

update mysql.user set authentication_string=password('123456') where user='root' ;

6,回到第二步骤去掉加上的
skip-grant-tables
保存 重启mysql就ok了

猜你喜欢

转载自blog.csdn.net/weixin_42125267/article/details/83153387