提示:access denied for user ‘root‘@‘localhost‘ using password yes
系统:windows7 64
1. 管理员登陆系统,停止 MySQL 服务或者结束 MySQL 进程。
2. 启动 WINDOWS 的命令行窗口(即通常的 DOS 窗口),切换到你的 “MySQL\bin” 目录下。
例如我的是 “D:\SERVER\MySQL\bin”,然后执行下面的粗体的命令:
(注意你的 “my-default.ini” 位置)
Microsoft Windows7 [版本 5.1.2600]
(C) 版权所有 1985-2001 Microsoft Corp.
C:\Documents and Settings\MMC>d:
D:\>cd D:\SERVER\MySQL\bin
D:\SERVER\MySQL\bin>mysqld --defaults-file="D:\SERVER\MySQL5122\my-default.ini" --console --skip-grant-tables
090801 4:43:54 InnoDB: Started; log sequence number 0 585546
090801 4:43:54 [ERROR] Can‘t open and lock privilege tables: Table ‘mysql.servers‘ doesn‘t exist
090801 4:43:54 [Note] mysqld: ready for connections.
Version: ‘5.1.22-rc-community‘ socket: ‘‘ port: 3306 MySQL Community Server (GPL)
_
只要出现下面信息,就说明 MySQL 已经起来了。
Version: ‘5.1.22-rc-community‘ socket: ‘‘ port: 3306 MySQL Community Server (GPL)
3. 不关闭此命令行窗口,重新打开一个命令行窗口,同样切到 “mysql\bin” 目录下,然后执行下面的粗体的命令:
C:\Documents and Settings\MMC>d:
D:\>cd D:\SERVER\MySQL\bin
D:\SERVER\MySQL\bin>mysql -u root mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.22-rc-community MySQL Community Server (GPL)
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.
mysql>
到这步,我想任何一个使用 MySQL 的人都知道后面要做什么了!(^a^)
mysql>
mysql> UPDATE user SET Password=PASSWORD(‘mynewpass‘) where USER=‘root‘;
Query OK, 2 rows affected (0.05 sec)
Rows matched: 2 Changed: 2 Warnings: 0
mysql> FLUSH PRIVILEGES;
Query OK, 0 rows affected (0.02 sec)
mysql> quit
Bye
4. 好了到此步,可以关闭第一个 DOS 窗口了。打开系统服务控制窗口(控制面板--管理工具--服务),启动 MySQL 服务。
5. 在剩下的第二个 DOS 窗口中,用新的 ROOT 密码连接 MySQL。
D:\SERVER\MySQL5122\bin>mysql -u root -p
Enter password: ********
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 2
Server version: 5.1.22-rc-community MySQL Community Server (GPL)
Type ‘help;‘ or ‘\h‘ for help. Type ‘\c‘ to clear the buffer.
mysql> quit
Bye
至此,系统恢复 ROOT 用户管理权限完成。
Access denied for user 'root'@'localhost' (using password: YES)
原文:http://blog.csdn.net/gggg_ggg/article/details/50628354