-
Windows:
- 1.以系統(tǒng)管理員身份登陸系統(tǒng)。 - 2.打開cmd-----net start 查看mysql是否啟動(dòng)。啟動(dòng)的話就停止net stop mysql. - 3.我的mysql安裝在d:\usr\local\mysql4\bin下。 - 4.跳過權(quán)限檢查啟動(dòng)mysql. - d:\usr\local\mysql\bin\mysqld-nt --skip-grant-tables - 5.重新打開cmd。進(jìn)到d:\usr\local\mysql4\bin下: - d:\usr\local\mysql\bin\mysqladmin -u root flush-privileges password "newpassword" - d:\usr\local\mysql\bin\mysqladmin -u root -p shutdown 這句提示你重新輸密碼。 - 6.在cmd里net start mysql - 7.搞定了。
-
Linux:
-
MySQL root密碼的恢復(fù)方法之一
-1.KILL掉系統(tǒng)里的MySQL進(jìn)程; - killall -TERM MySQLd -2.用以下命令啟動(dòng)MySQL,以不檢查權(quán)限的方式啟動(dòng); - safe_MySQLd --skip-grant-tables & -3.然后用空密碼方式使用root用戶登錄 MySQL; - MySQL -u root -4.修改root用戶的密碼; - MySQL> update MySQL.user set password=PASSWORD('新密碼') where User='root'; - MySQL> flush privileges; - MySQL> quit - 重新啟動(dòng)MySQL,就可以使用新密碼登錄了。
-
MySQLroot密碼的恢復(fù)方法二
-
有可能你的系統(tǒng)沒有 safe_MySQLd 程序(比如我現(xiàn)在用的 ubuntu操作系統(tǒng), apt-get安裝的MySQL) , 下面方法可以恢復(fù)
- 1.停止MySQLd;
- sudo /etc/init.d/MySQL stop
- (您可能有其它的方法,總之停止MySQLd的運(yùn)行就可以了)
- 2.用以下命令啟動(dòng)MySQL,以不檢查權(quán)限的方式啟動(dòng);
- MySQLd --skip-grant-tables &
- 3.然后用空密碼方式使用root用戶登錄 MySQL;
- MySQL -u root
- 4.修改root用戶的密碼;
- MySQL> update MySQL.user set password=PASSWORD('newpassword') where User='root';
- MySQL> flush privileges;
- MySQL> quit
- 重新啟動(dòng)MySQL
- /etc/init.d/MySQL restart
- 就可以使用新密碼 newpassword 登錄了。