【转】windows下mysql5.1忘记root密码解决方法[win7]

windows下mysql5.1忘记root密码解决方法[win7]

(2010-12-07 21:08:38)
标签:

mysql数据库

windows

密码

分类:

步骤如下:
1.停止mysql服务(以管理员身份,在cmd命令行下运行) net stop mysql
2.使用 mysqld –skip-grant-tables 命令启动mysql数据库

D:/>net stop mysql
MySQL 服务正在停止.
MySQL 服务已成功停止。

D:/>mysqld --skip-grant-tables

3.新开一个cmd窗口,进行如下操作

D:/>mysql -uroot
Welcome to the MySQL monitor.  Commands end with ; or /g.
Your MySQL connection id is 1
Server version: 5.1.26-rc-community MySQL Community Server (GPL)

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

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

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

mysql>

4.打开任务管理器,停止mysql,mysqld进程,使用net start mysql启动mysqld服务,就可以使用root用户 root密码进入数据库了

mysql -uroot -proot

补充说明:
1.mysqld使用说明可以使用如下命令获取查看:

mysqld --verbose --help > d:/mysqld_help.txt

帮助中–skip-grant-tables的帮助为:

--skip-grant-tables Start without grant tables. This gives all users FULL
                      ACCESS to all tables!

所以我们可以使用mysql -uroot而不用密码直接登陆mysql,而且可以修改任何表。

2.如果没有配置mysql的环境变量,需要cd到mysql的bin目录执行上面的命令。
3.可参考:http://www.kuqin.com/database/20080306/4249.html ,但是5.1可能没有mysqld-nt命令,其实mysqld就是对应的mysqld-nt命令。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值