前言:这事情谁遇到谁头疼!网上找到的方法,有些不可以,我在这里根据大家的方法结合我的情况,把解决方法方法写出来,希望你们别跟我一起头疼。
Windows:
1. 管理员登陆系统,停止mysql服务或者结束mysqld-nt进程
在cmd下键入net start,之后察看列表中是否有mysql,如果有,就执行net stop mysql,这样就停止了mysql的服务。
2. 进入命令行,来到mysql的bin目录下,比如我的是C:\Program Files\MySQL\MySQL Server 5.0\bin。
cd C:\Program Files\MySQL\MySQL Server 5.0\bin,回车。
3. 运行 d:\mysql\bin\mysqld-nt --skip-grant-tables 启动mysql,关闭权限的检查。这时,窗口动不了了(我至始至终都没有关闭这个窗口),所以下一步的时候,你要重新开启一个cmd.
4. 运行 d:\mysql\bin\mysqladmin -u root flush-privileges password "newpassword" 重设root密码
我的运行到这一步时,提示
“mysqladmin: connect to server at 'localhost' failed7 Y) j" C) D8 P: s/ `
error: 'Access denied for user 'root'@'localhost' (using password: NO)'6 W# C' ”
5. 接下来,咋办呢,我在C:\Program Files\MySQL\MySQL Server 5.0\bin目录下,依次敲入
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root mysql
mysql> UPDATE user SET password=PASSWORD("newpassword") WHERE user='name';
mysql> FLUSH PRIVILEGES;
mysql> QUIT
6.重新登陆(偶没有重启mysql服务,好懒哦)
C:\Program Files\MySQL\MySQL Server 5.0\bin>mysql -u root -p
Enter password: **********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 3
Server version: 5.0.41-community-nt MySQL Community Edition (GP
Type 'help;' or '\h' for help. Type '\c' to clear the buffer.
mysql> show databases;
+--------------------+
| Database |
+--------------------+
| information_schema |
| apple |
| mysql |
| test |
| testlink |
| testlink162 |
+--------------------+
哇哇,got it!
主要引自:http://tech.techweb.com.cn/thread-210740-1-1.html