遺忘 MySQL root 密碼是資料庫管理中常見的棘手問題。本文詳細說明在 Windows 與 Linux/Unix 系統下,透過跳過權限驗證模式啟動 MySQL 服務,進而重置 root 密碼的完整操作流程。
net stop mysql 停止服務。C:\MySQL\bin(視實際安裝路徑調整)。mysqld-nt --skip-grant-tablesmysqld --skip-grant-tables)mysqladmin -u root flush-privileges password "新密碼"mysqladmin -u root -p shutdownnet start mysql 啟動服務。mysql -u root -p。kill 或 systemctl stop mysqld。mysqld_safe --skip-grant-tables &mysqladmin -u root flush-privileges password "新密碼"ALTER USER 'root'@'localhost' IDENTIFIED BY '新密碼'; 語法。