这里会显示出您选择的修订版和当前版本之间的差别。
— |
vps:mysql:forget-password [2011/09/15 02:26] (当前版本) |
||
---|---|---|---|
行 1: | 行 1: | ||
+ | |||
+ | ====== MySQL忘记密码的恢复办法 ====== | ||
+ | ===== Windows MySQL密码恢复 ===== | ||
+ | |||
+ | 1.用系统管理员登陆系统。 | ||
+ | |||
+ | 2.停止MySQL的服务。 | ||
+ | |||
+ | 3.进入命令窗口,然后进入MySQL的安装目录,比如我的安装目录是c:\mysql,进入C:\mysql\bin | ||
+ | |||
+ | 4.跳过权限检查启动MySQL, | ||
+ | |||
+ | |||
+ | c:\mysql\bin>mysqld-nt --skip-grant-tables | ||
+ | |||
+ | 5.重新打开一个窗口,进入c:\mysql\bin目录,设置root的新密码 | ||
+ | <code> | ||
+ | c:\mysql\bin>mysqladmin -u root flush-privileges password "newpassword" | ||
+ | c:\mysql\bin>mysqladmin -u root -p shutdown | ||
+ | </code> | ||
+ | 将newpassword替换为你要用的root的密码,第二个命令会提示你输入新密码,重复第一个命令输入的密码。 | ||
+ | |||
+ | 6.停止MySQL Server,用正常模式启动Mysql | ||
+ | |||
+ | 7.你可以用新的密码链接到Mysql了。 | ||
+ | |||
+ | ===== Unix&Linux MySQL 密码恢复 ===== | ||
+ | |||
+ | 1.用root或者运行mysqld的用户登录系统; | ||
+ | |||
+ | 2.利用kill命令结束掉mysqld的进程; | ||
+ | |||
+ | 3.使用--skip-grant-tables参数启动MySQL Server | ||
+ | |||
+ | <code> | ||
+ | shell>;mysqld_safe --skip-grant-tables & | ||
+ | </code> | ||
+ | 4.为root@localhost设置新密码 | ||
+ | |||
+ | <code> | ||
+ | shell>mysqladmin -u root flush-privileges password "newpassword" | ||
+ | </code> | ||
+ | |||
+ | ==== 重启MySQL Server ==== | ||
+ | <code> | ||
+ | kill -9 mysql进程 | ||
+ | mysqld_safe --user=mysql --skip-grants-table | ||
+ | </code> |