帮助文档>数据库类 > 忘记root密码怎么办?怎么破解?

忘记root密码怎么办?怎么破解?

发布时间:2021-12-20 08:43

Windows平台下MYSQL破解root密码(忘记root密码的解决方法)

1、停止MYSQL服务,开始→运行→CMD打开DOS窗口,输入 net stop mysql

C:/Documents and Settings/skate_db>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。
2、在开始→运行→CMD命令行窗口,进入MYSQL安装目录

C:/Documents and Settings/skate_db>cd C:/Program Files/MySQL/MySQL Server 5.0/bin
3、进入mysql安全模式,即当mysql起来后,不用输入密码就能进入数据库。

C:/Program Files/MySQL/MySQL Server 5.0/bin>mysqld-nt --skip-grant-tables
100423 10:27:27 [Warning] Changed limits: max_open_files: 2048  max_connections:
800  table_cache: 619
4、重新打开一个开始→运行→CMD命令行窗口,输入mysql –u root -p,使用空密码的方式登录MySQL(不用输入密码,直接按回车)


C:/Documents and Settings/skate_db>mysql -u root -p
Enter password:
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 1 to server version: 5.0.22-community-nt
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>

5、输入以下命令开始修改root用户的密码(注意:命令中mysql.user中间有个“点”)

命令:mysql> update mysql.user set password=PASSWORD('新密码') where User='root';


mysql> update mysql.user set password=password('root') where user='root';
Query OK, 2 rows affected (0.06 sec)
Rows matched: 2  Changed: 2  Warnings: 0

6、保存配置,刷新权限表


mysql> flush privileges;
Query OK, 0 rows affected (0.00 sec)
mysql>

7、退出


mysql> quit

这样MYSQL超级管理员账号ROOT已经重新设置好了,因为心在mysql还是运行在安全模式下,所以在windows的任务管理器里kill掉mysql-nt.exe 这个进程,重新启动mysql,用新设置的root密码登录。


C:/Documents and Settings/skate_db>net start mysql
MySQL 服务已经启动成功。
C:/Documents and Settings/skate_db>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 2 to server version: 5.0.22-community-nt
Type 'help;' or '/h' for help. Type '/c' to clear the buffer.
mysql>

-----end-----

本文导读

客户热线:037125966675

客户服务中心
云产品 服务器 合 作                  Skype