mysql-8 错误"ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)"解决

在Centos8服务器上连接mysql-8时出现

ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

无法登陆, 重置密码即可

解决:

首先打开my.cnf文件  vim /etc/my.cnf

在  [mysqld] 下 添加 skip-grant-tables ,打开mysql安全模式,可以免密登陆

重启之后,再尝试登陆mysql

 

进入数据库后,执行 use mysql

然后置空 authentication_string字段 ,执行 update  user set authentication_string= '' where user='root';

随后执行  alter user 'root'@'localhost' identified by '输入你要修改的密码';

    或者 alter user 'root'@'%' identified by '输入你要修改的密码';

退出mysql,把my.cnf文件中  skip-grant-tables 注释掉

重启mysql服务

这个错误就解决了

posted on 2020-08-16 14:41  晴天在下雨  阅读(594)  评论(0)    收藏  举报

导航