以 --skip-grant-tables 啟動 MySQL,跳過權限驗證,無密碼登入修改 mysql.user 表,再正常重啟。
killall -TERM mysqld/usr/bin/mysqld_safe --skip-grant-tables &(或 mysqld --skip-grant-tables &)mysql -u rootUSE mysql;UPDATE user SET Password=PASSWORD('new_pass') WHERE User='root';FLUSH PRIVILEGES;killall -TERM mysqldservice mysql startnet stop mysqlbin,啟動:mysqld --skip-grant-tables(窗口將阻塞)mysqld 進程,重新啟動服務:net start mysql--skip-networking 禁止外部連入。user 表 Host 列,確保無 % 通配符風險。