欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

找回MySQL的root密码

程序员文章站 2022-03-01 18:01:33
...

1.
C:\wamp\bin\mysql\mysql5.1.36>cd bin

C:\wamp\bin\mysql\mysql5.1.36\bin>dir
 Volume in drive C has no label.
 Volume Serial Number is 38DC-C60C

 Directory of C:\wamp\bin\mysql\mysql5.1.36\bin

10/22/2009  12:16 PM    <DIR>          .
10/22/2009  12:16 PM    <DIR>          ..
06/17/2009  11:18 AM         2,359,296 libmySQL.dll
06/17/2009  11:18 AM         2,089,600 myisamchk.exe
06/17/2009  11:18 AM         1,979,008 myisamlog.exe
06/17/2009  11:18 AM         2,007,680 myisampack.exe
06/17/2009  11:18 AM         1,966,720 myisam_ftdump.exe
06/17/2009  11:18 AM         2,347,648 mysql.exe
06/17/2009  11:18 AM         2,282,112 mysqladmin.exe
06/17/2009  11:18 AM         2,368,128 mysqlbinlog.exe
06/17/2009  11:18 AM         2,278,016 mysqlcheck.exe
06/17/2009  11:18 AM         6,582,912 mysqld.exe
06/17/2009  11:18 AM         2,331,264 mysqldump.exe
06/17/2009  11:18 AM         2,273,920 mysqlimport.exe
02/06/2009  01:17 AM         2,971,776 MySQLInstanceConfig.exe
06/17/2009  11:18 AM         2,273,920 mysqlshow.exe
06/17/2009  11:18 AM         1,802,880 mysql_upgrade.exe
06/17/2009  11:18 AM         1,728,512 my_print_defaults.exe
06/17/2009  11:18 AM         1,716,224 perror.exe
06/17/2009  11:18 AM         1,703,936 resolveip.exe
              18 File(s)     43,063,552 bytes
               2 Dir(s)   3,049,091,072 bytes free

C:\wamp\bin\mysql\mysql5.1.36\bin>mysqld-nt
'mysqld-nt' is not recognized as an internal or external command,
operable program or batch file.

C:\wamp\bin\mysql\mysql5.1.36\bin>mysqld -nt --skip-grant-tables

//此命令执行后会挂起,此时新开cmd,执行修改密码操作;


2.
update the password
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

C:\Documents and Settings\Administrator>cd C:\wamp\bin\mysql\mysql5.1.36

C:\wamp\bin\mysql\mysql5.1.36>cd bin

C:\wamp\bin\mysql\mysql5.1.36\bin>mysql.exe
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

C:\wamp\bin\mysql\mysql5.1.36\bin>
C:\wamp\bin\mysql\mysql5.1.36\bin>mysql.exe
ERROR 1045 (28000): Access denied for user 'ODBC'@'localhost' (using password: NO)

//一些方案说直接执行mysql登录后修改密码,我试后行不通;
//直接使用mysqladmin命令修改密码

C:\wamp\bin\mysql\mysql5.1.36\bin>mysqladmin.exe -u root flush-privileges password "111111"

C:\wamp\bin\mysql\mysql5.1.36\bin>mysqladmin -u root -p shutdown
//此命令执行后会要求你输入密码,与以上所设相同即可
Enter password: ******

C:\wamp\bin\mysql\mysql5.1.36\bin>


3.返回第一个窗口,已经自动停止;启动mysql,使用新密码登录,ok。