MySQL 登陆错误:access denied for user root @localhost

时间:2021-08-07 19:23:21

MySQL5.7登录提示:access denied for user root @localhost

个人解决方法:

编辑配置项:

vim /etc/my.cnf

跳过身份验证:

skip-grant-tables

重启服务:

systemctl restart mysqld

进入MySQL:

mysql -uroot -p

use mysql;

更新密码

update user set authentication_string = password("*******") where user="root";
exit
去掉之前的配置项,重启即可登录