mysql8.0+修改用戶密碼


查看初始安裝密碼登陸:
[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;




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM