當 MySQL 忘記管理密碼的解決方法(Linux 版)
如果 MySQL 正在運作,請先關閉,關閉方法:service mysqld stop
或
killall -TERM mysqld
接下來,重新開啟 MySQL,請額外加上指令:
/usr/bin/safe_mysqld --skip-grant-tables &
(請注意執行程式的路徑,請替換成你的程式路徑)
再來就是進入 MySQL:
# mysql (這個也是,如果直接執行找不到程式,請打完整路徑)
>use mysql
>update user set password=password("新密碼") where user="root";
>flush privileges;
>exit;
關閉現在執行的 MySQL,重新正常啟動 MySQL。
若是碰到新版 MySQL 的密碼演算法不同,可用下列方式改密碼
>update user set password=old_password("新密碼") where user="root";
頁:
[1]