MySQL 5.5 Windows 環境忘記 root 密碼,雙 CMD 視窗配合 mysqld --skip-grant-tables 重置密碼完整步驟。
net stop mysql 停止服務。cd C:\Program Files\MySQL\MySQL Server 5.5\bin → mysqld --skip-grant-tables(光標閃爍保持)。mysql 免密進入。USE mysql;
UPDATE user SET password = PASSWORD('oracle') WHERE user = 'root';
FLUSH PRIVILEGES; QUIT;
mysqld.exe。net start mysql 正常啟動。mysql -uroot -poracle 驗證。net stop mysql
mysqld.exe --skip-grant-tables # 視窗 1
# 視窗 2
mysql
UPDATE user SET password = PASSWORD('new_password') WHERE user = 'root';
FLUSH PRIVILEGES; QUIT
# 結束視窗 1 進程
net start mysql
mysql -u root -pnew_password
核心同 5.6:雙視窗、保持 --skip-grant-tables 進程、FLUSH PRIVILEGES 生效。