MySQL忘記密碼後重置密碼

Windows:
1.用系統管理員登陸系統。
2.停止MySQL的服務。 打開命令行窗口:        Net stop mysql
3.進入命令窗口,然後進入MySQL的安裝目錄,比如我的安裝目錄是c:mysql,進入C:mysqlbin
4.跳過權限檢查啓動MySQL,
c:mysqlbin>mysqld-nt --skip-grant-tables
5.重新打開一個窗口,進入c:mysqlbin目錄,設置root的新密碼
c:mysqlbin>mysqladmin -u root flush-privileges password "newpassword"
c:mysqlbin>mysqladmin -u root -p shutdown
將newpassword替換爲你要用的root的密碼,第二個命令會提示你輸入新密碼,重複第一個命令輸入的密碼。
6.停止MySQL Server,用正常模式啓動Mysql ,打開命令行窗口: Net start mysql
7.你可以用新的密碼鏈接到Mysql了。

Unix&Linux:
1.用root或者運行mysqld的用戶登錄系統
2.結束mysql服務

    sudo /etc/init.d/mysql stop
3.使用--skip-grant-tables參數啓動MySQL Server
    mysqld_safe --skip-grant-tables
4.爲root@localhost設置新密碼
    mysqladmin -u root flush-privileges password "newpassword"

5.重啓MySQL Server

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章