| First things first. Log in as root and stop the mysql daemon. sudo /etc/init.d/mysql stop Now lets start up the mysql daemon and skip the grant tables which store the passwords. sudo mysqld_safe --skip-grant-tables& (press Ctrl+C now to disown the process and start typing commands again) You should see mysqld start up successfully. If not, well you have bigger issues. Now you should be able to connect to mysql without a password. sudo mysql --user=root mysql update user set Password=PASSWORD('new-password'); flush privileges; exit; Now kill your running mysqld then restart it normally. sudo killall mysqld_safe& (press Ctrl+C now to disown the process and start typing commands again) /etc/init.d/mysql start You should be good to go. Try not to forget your password again. |
mysql root密码重置
最新推荐文章于 2025-07-23 14:27:56 发布
本文详细介绍了使用命令行界面通过sudo命令登录root账户,停止MySQL服务,然后跳过授权表重启服务,从而实现无密码连接MySQL数据库的方法。最后,文章指导了如何设置新的密码并恢复正常服务。

2333

被折叠的 条评论
为什么被折叠?



