net stop mysql 停止服務d:\usr\local\mysql\bin\mysqld-nt --skip-grant-tablesmysqladmin -u root flush-privileges password "newpassword"mysqladmin -u root -p shutdown(輸入新密碼關閉)net start mysql 正常啟動killall -TERM mysqld
safe_mysqld --skip-grant-tables &
mysql -u root
mysql> UPDATE mysql.user SET password=PASSWORD('新密碼') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> QUIT
/etc/init.d/mysql restart
sudo /etc/init.d/mysql stop
mysqld --skip-grant-tables &
mysql -u root
mysql> UPDATE mysql.user SET password=PASSWORD('newpassword') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> QUIT
sudo /etc/init.d/mysql restart
--skip-grant-tables 期間任何人無密碼可登入,**務必在安全網絡環境下操作,完成後立即重啟**password 欄改為 authentication_string,語法調整為:UPDATE mysql.user SET authentication_string=PASSWORD('pwd') WHERE User='root';ALTER USER 'root'@'localhost' IDENTIFIED BY 'pwd';備份好配置文件,定期演練密碼恢復流程,關鍵時刻不慌。