systemctl stop mysqld 或 service mysql stop 或 killall mysqldmysqld_safe --skip-grant-tables &mysql -u rootmysql> UPDATE mysql.user SET authentication_string=PASSWORD('新密碼') WHERE User='root';
mysql> FLUSH PRIVILEGES;
mysql> QUIT;
MySQL 5.7+ 欄位為authentication_string,5.6 及之前為Password。建議先DESC mysql.user;確認欄位名。
systemctl restart mysqldmysql -u root -p'新密碼'net stop mysqlmysqld --skip-grant-tables(在另一視窗保持運行)mysql -u root 免密登入net stop mysql → net start mysql 重啟服務--skip-grant-tables 期間任何人可無密碼登入 Root,務必在內網/單用戶模式下操作