密码恢复有时候,会将root密码给忘记了,就需要对MySQL进行密码恢复 。
在/etc/my.cnf中,的[mysqld]内,加入如下内容:
skip-grant-table//改为安全模式,无法密码登陆
重启mysqld
systemctl restart mysqld
进入重置密码
mysql -u root -p//空密码,直接回车use mysql;update user set authentication_string='' where user='root';//先清空密码
注释掉my.cnf中的skip-grant-table,再重启mysqld 。然后就可以免密码进入,再修改密码 。
mysql -u root -p//不用输入密码,直接进入alter user 'root'@'localhost' identified with mysql_native_password by '三种或以上的八位字符';//修改密码,并将密码插件更改为mysql_native_password
现在就恢复正常使用了 。
推荐阅读
- ping 域名+端口 Windows和Linux下检测网络是否可用
- 在Centos7上安装图形化桌面工具
- 信用卡用几个月可以提额
- 保养时机油没用完?这样保存下次还能用!
- 下雨天,水淹车,上了保险有的也不赔!别大意!
- 线上手机和线下手机有什么区别
- 胃脘下俞穴位的准确位置图 胃俞穴_人体穴位查询
- 菊花茶喝了会下火,孕妇喝菊花茶好不好
- “恕我直言,信阳毛尖天下第一
- PHP初学者总会遇到非常头疼问题,今天给你们总结一下