mysql 丢失root密码补救办法

来源:互联网 发布:淘宝网是谁创建的 编辑:程序博客网 时间:2024/04/26 01:59

前几天把root密码忘了,于是在网上转了半天,也没有找到一个完整无错的答案。于是经过几十次的尝试后,终于搞定了。也算对得起自己了。

这里把自己的详细设置方法告诉和我一样的菜鸟,希望对你们有点帮助,同时自己也做个备份。

我的mysql为MySQL - 5.0.23:

1、在开始菜单“运行”栏里输入“CMD”,进入到了命令行下
C:/Documents and Settings/millken>
C:/Documents and Settings/millken>.Net stop mysql
C:/Documents and Settings/millken>mysqld-nt --skip-grant-tables
C:/Documents and Settings/millken>

2、新开一个CMD窗口:
*************************************************************************
Microsoft Windows [版本 5.2.3790]
(C) 版权所有 1985-2003 Microsoft Corp.

C:/Documents and Settings/millken>mysql -u root
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 18 to server version: 5.0.23-community-nt

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> use mysql
Database changed
mysql> update user set password=password("root") where host="localhost" and user="root";
Query OK, 0 rows affected (0.00 sec)
Rows matched: 1 Changed: 0 Warnings: 0

mysql> set password for "root"@"localhost"=old_password("root");
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables
option so it cannot execute this statement
mysql> exit;
Bye

C:/Documents and Settings/millken>d:

D:/>mysqladmin -u root shutdown

D:/>.Net start mysql

MySQL 服务已经启动成功。


D:/>cd www

D:/WWW>cd mysql

D:/WWW/MYSQL>cd bin

D:/WWW/MYSQL/bin>mysql -u root -p
Enter password: ****
Welcome to the MySQL monitor. Commands end with ; or /g.
Your MySQL connection id is 35 to server version: 5.0.23-community-nt

Type 'help;' or '/h' for help. Type '/c' to clear the buffer.

mysql> set password for 'root'@'localhost'=old_password("root");
Query OK, 0 rows affected (0.00 sec)

mysql>

 

至此就大功告成了,注意一点的是因为5.0.1版Mysql的password算法和3.23.44的算法不一样了,所以要运行最后一句,不然Phpmyadmin下会进不了。

该文章转载自网络大本营:http://www.xrss.cn/Info/10790.Html 

原创粉丝点击