如果忘记了 mysql5.7 数据库的 ROOT 用户的密码,如何找回?

vim /etc/my.cnf
追加一行: skip-grant-tables
service mysqld restart
空密码登录 mysql -uroot -p
use mysql;
update user set authentication_string=password("newPassword") where user='root';
flush privileges;
exit;
将 /etc/my.cnf 中追加的内容去掉.
service mysqld restart
使用新设置的密码登录mysql

版权声明:
作者:Curry
链接:http://cp.it-cxy.top/index.php/2024/05/14/%e5%a6%82%e5%bf%98%e8%ae%b0%e4%ba%86-mysql5-7-%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9a%84-root-%e7%94%a8%e6%88%b7%e7%9a%84%e5%af%86%e7%a0%81%ef%bc%8c%e5%a6%82%e4%bd%95%e6%89%be%e5%9b%9e/
来源:CorePress
文章版权归作者所有,未经允许请勿转载。

THE END
分享
二维码
< <上一篇
下一篇>>
文章目录
关闭
目 录