【踩坑】MySQL忘记密码
前言
MySQL忘记密码,或者安装后没有找到默认密码无法登录的解决办法
修改配置文件
- 使用安全模式
1 | [mysqld] |
修改密码
- 重启服务后,无密码登录并修改密码
1 | mysql -uroot -p |
还原配置文件
1 | [mysqld] |
再次踩坑
- 在安全模式下登录的MySQL在修改密码时报错:
The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
解决问题
- 关闭只读权限
1 | SET GLOBAL read_only=0; |