cenots 7 | mysql 57 更改密码

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

密码错误引起的错误,需要更改密码。
1.重置密码的第一步就是跳过MySQL的密码认证过程,方法如下:

#vim /etc/my.cnf

在[mysqld]后面任意一行添加skip-grant-tables用来跳过密码验证的过程,保存文档并退出。

2.重起mysql

systemctl restart mysqld

3.重启之后输入mysql即可进入mysql。并更改密码。

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

flush privileges;

quit

4.删除之前第一步添加的内容

vim /etc/my.cnf

找到删除即可

发布了134 篇原创文章 · 获赞 57 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/stone_fall/article/details/102169521
今日推荐