遺忘 Root 密碼時,以 --skip-grant-tables 跳過權限檢查啟動,空密碼登入修改密碼。
mysqld-nt.exe → 結束進程mysqld-nt --skip-grant-tablesmysql -u root (不需 -p)UPDATE mysql.user SET Password=PASSWORD('新密碼') WHERE User='root';
FLUSH PRIVILEGES;
QUIT;
--skip-grant-tables 視窗,重新啟動 MySQL 服務killall mysqld
mysqld_safe --skip-grant-tables &
mysql -u root
# 同樣 UPDATE ... FLUSH PRIVILEGES
killall mysqld
service mysql start
--skip-grant-tables 期間任何人可無密碼登入具備完整權限,務必在安全網路/單用戶模式下操作,完成即關閉Password 欄位改名 authentication_string,語法調整:UPDATE mysql.user SET authentication_string=PASSWORD('新密碼') WHERE User='root';