Linux教程網
Linux教程網
Linux教程網
您现在的位置: Linux教程網 >> UnixLinux >  >> Linux基礎 >> 關於Linux

Linux 重設 MySQL root 密碼(快速版)

若 MySQL root 密碼忘記,可用跳過權限檢查的方式快速重設。

停止 MySQL

/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;

重啟 MySQL

先結束 mysqld 進程,再啟動:

killall mysqld
/etc/init.d/mysql start

Copyright © Linux教程網 All Rights Reserved