先找到mysql目录下的my.cnf,添加skip-grant-tables,保存退出。(该命令意思是免密码登陆)然后重启mysql,输入命令:systemctl restart mysqld.service,然后执行以下步骤:
1 mysql -uroot -p
2 mysql>use mysql;
3 mysql> update user set authentication_string=passworD(“new password”) where user=‘root’;
4 mysql> exit;
然后重启打开my.cnf,把此行skip-grant-tables删除即可。
Centos7的mysql(版本5.7以上)忘记密码解决方法
最新推荐文章于 2023-10-30 19:54:24 发布