重置MySQL8.0 Root密码
- 停止MySQL服务
- 跳过权限检查启动MySQL服务:
1 | sudo mysqld_safe --skip-grant-tables & |
- 使用root账号登录MySQL:
1 | mysql -u root |
- 更新Root密码:
1 | flush privileges; |
如不先执行“flush privileges;”,则可能会提示以下错误信息:
1 | ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement |
- 刷新权限:
1 | flush privileges; |
- 重启MySQL服务。