Windows下丢失mysql root密码后的详细解决方法

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

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

我的mysql为MySQL - 5.0.23:

1、在开始菜单“运行”栏里输入“CMD”, http://www.lololuoluo.com ,进入到了命令行下
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下会进不了。
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值