若 MySQL root 密碼忘記,可用跳過權限檢查的方式快速重設。
/etc/init.d/mysql stop 或 /etc/init.d/mysqld stop
/usr/local/mysql/bin/mysqld_safe --skip-grant-tables
登入:
/usr/local/mysql/bin/mysql -u root mysql
執行:
update user set password = Password('要設置的密碼') where User = 'root';
flush privileges;
exit;
先結束 mysqld 進程,再啟動:
killall mysqld
/etc/init.d/mysql start