Mysql5.7如何修改root密碼
版本更新,原來(lái)user里的password字段已經(jīng)變更為authentication_string
版本更新 緣故,好多網(wǎng)上的教程都不適用了,甚至連官網(wǎng)的文檔也不是能夠順利操作的。
如果 MySQL 正在運(yùn)行,首先殺之:
killall -TERM mysqld。
運(yùn)行
mysqld_safe --skip-grant-tables &
如果此時(shí)不想被遠(yuǎn)程連接:
mysqld_safe --skip-grant-tables --skip-networking &
使用mysql連接server
更改密碼:
update mysql.user set authentication_string=password(123qwe) where user=root and Host = localhost;
*特別提醒注意的一點(diǎn)是,新版的mysql數(shù)據(jù)庫(kù)下的user表中已經(jīng)沒(méi)有Password字段了
而是將加密后的用戶密碼存儲(chǔ)于authentication_string字段
mysql> flush privileges;
mysql> quit;
修改完畢。重啟
killall -TERM mysqld。
mysqld_safe &
然后mysql就可以連接了
但是此時(shí)操作似乎功能不完全,還要alter user...
alter user root@localhost identified by 123
會(huì)員登錄
賬號(hào)登錄還沒(méi)有賬號(hào)?立即注冊(cè)