linux下重置MySQL密码
时间: 2023-11-21 16:17:55 浏览: 92
可以通过以下步骤来重置MySQL密码:
1. 停止MySQL服务:sudo systemctl stop mysql
2. 启动MySQL服务,并跳过授权表:sudo mysqld_safe --skip-grant-tables &
3. 以管理员身份登录MySQL:sudo mysql -u root
4. 切换到MySQL数据库:use mysql;
5. 更新root用户的密码:update user set authentication_string=password('新密码') where user='root';
6. 刷新权限:flush privileges;
7. 退出MySQL:exit;
8. 重启MySQL服务:sudo systemctl start mysql
请注意,这只是一种简单的方法,如果您的MySQL配置比较复杂,可能需要采取其他措施。
相关问题
linux如何重置mysql密码
您可以通过以下步骤重置MySQL密码:
1.停止MySQL服务:sudo systemctl stop mysql
2.使用以下命令跳过授权表来重新启动MySQL服务:sudo mysqld_safe --skip-grant-tables &
3.连接到MySQL命令行:mysql -u root
4.在MySQL命令行中,使用以下命令更新密码:UPDATE mysql.user SET authentication_string=PASSWORD('your_new_password') WHERE User='root' AND Host='localhost';
5.刷新权限表:FLUSH PRIVILEGES;
6.退出MySQL命令行:quit;
7.停止MySQL服务:sudo systemctl stop mysql
8.使用以下命令启动MySQL服务:sudo systemctl start mysql
现在,您可以使用新密码登录MySQL。
linux重置mysql密码
1. 停止MySQL服务:sudo service mysql stop
2. 启动MySQL服务并跳过权限验证:sudo mysqld_safe --skip-grant-tables &
3. 进入MySQL命令行:mysql -u root
4. 切换到mysql数据库:use mysql;
5. 更新root用户密码:update user set authentication_string=password('新密码') where user='root';
6. 刷新权限:flush privileges;
7. 退出MySQL命令行:exit;
8. 停止MySQL服务:sudo service mysql stop
9. 启动MySQL服务:sudo service mysql start
10. 使用新密码登录MySQL:mysql -u root -p新密码
阅读全文
相关推荐














