记一次 MySQL for Linux错误 ERROR 1045 (28000) 解决方案

报错信息:MySQL for Linux错误 ERROR 1045 (28000): Access denied for user ‘root’@‘localhost’ (using password: YES)
1、跳过MySQL的密码认证过程
(1)、修改 /etc/my.cnf 文件

[root@localhost ~]# cp /usr/share/mysql/my-default.cnf /etc/my.cnf
[root@localhost ~]#vim /etc/my.cnf

(2)加入信息
[mysqld]后面任意一行添加“skip-grant-tables”用来跳过密码验证的过程
在这里插入图片描述
保存并退出 :wq
2、重启Mysql服务

[root@localhost ~]# service mysql restart

在这里插入图片描述
3、重启之后输入 mysql 进入 mysql 。
在这里插入图片描述
4、重置密码

mysql> use mysql;
mysql> update user set password=password("你的新密码") where user="root";
mysql> flush privileges;
mysql> quit;

在这里插入图片描述
5、关闭mysql的 skip-grant-tables 模式

把“skip-grant-tables”删除或者注释掉。

6、重启mysql服务

[root@localhost ~]# service mysql restart

7、用修改后的密码登录mysql
在这里插入图片描述

猜你喜欢

转载自blog.csdn.net/qq_39162487/article/details/105446098