首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫

MySQL 忘記密碼恢復完整實戰記錄(Windows 2003 + MySQL 5.1)

     編輯:MySQL 資料庫相關知識

環境

Windows 2003 中文企業版 SP2、MySQL 5.1.55、PHP 5.2.17、IIS 6.0

破解步驟

  1. 管理員 CMD 執行 net stop mysql 停止服務
  2. 啟動跳過權限檢查:mysqld --skip-grant-tables 或 mysqld-nt --skip-grant-tables
  3. 新開 CMD 視窗操作:
    mysql -uroot
    UPDATE mysql.user SET password=PASSWORD('root') WHERE user='root';
    FLUSH PRIVILEGES;
  4. 工作管理員結束 mysql/mysqld 進程,net start mysql 重啟服務,即可用 root/root 登入

通用標準流程(Linux/Windows 通用)

  1. killall -TERM mysqld(Windows 用進程管理器)
  2. safe_mysqld --skip-grant-tables &(Windows:c:\mysql\bin\mysqld --skip-grant-tables)
  3. 無密碼登入:USE mysql; UPDATE user SET password=PASSWORD("new_pass") WHERE user="root"; FLUSH PRIVILEGES;
  4. mysqladmin -h hostname flush-privileges 或 FLUSH PRIVILEGES
  5. killall -TERM mysqld 再正常啟動

Windows 實操細節

  1. 關閉 MySQL 服務
  2. DOS 進入 mysql\bin,執行 mysqld-nt --skip-grant-tables(視窗會卡住)
  3. 另開 DOS 視窗 進入 mysql\bin,執行 mysql 進入提示符
  4. USE mysql; → UPDATE user SET password=PASSWORD("123456") WHERE user="root"; → FLUSH PRIVILEGES; → \q 退出
  5. 登出系統重新登入,啟動 MySQL,用 root/123456 登入

替代方案(直接改檔案)

關閉 MySQL,替換 data\mysql\user.MYD(結構未改時),或用十六進位編輯器修改 user.MYD 中 root 後 8 字元為 565491d704013245(密碼 123456)或 00 02 02 02 02 02 02 02(空密碼)。

附錄:SQL Server sa 密碼重置

Windows 驗證登入後執行:EXEC sp_password NULL, 'newpass', 'sa'(無舊密碼)或 EXEC sp_password 'old', 'new'(有舊密碼)。

  1. 上一篇文章:
  2. 下一篇文章:
Copyright © 程式碼之家 All Rights Reserved