mysql8.0+修改使用者密碼

流火行者發表於2018-11-04
檢視初始安裝密碼登陸:
[root@VM_133_71_centos yum.repos.d]# cat /var/log/mysqld.log|grep 'A temporary password'
2019-01-20T12:25:32.368343Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: lnj+*Jpum7hk

 

開始修改密碼



alter user 'root'@'%' identified by 'xxxx';
alter user 'root'@'localhost' identified by 'xxxx';

如果客戶端或者php連結的時候報下面的錯誤
Authentication plugin 'caching_sha2_password' cannot be loaded....

執行下面的sql就可以了
ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY 'mypwd#2018';

root@後面是user表的Host欄位的內容,新安裝預設是localhost,我這增加了遠端訪問,將localhost手動改成了%
改完了之後需要執行
flush privileges;



相關文章