MySQL-錯誤:2059 - Authentication plugin 'caching_sha2_password' cannot be loaded


MySQL-錯誤:2059-Authentication plugin 'caching_sha2_password' cannot be loaded

一 現象

使用docker鏡像創建容器后,mysql測試連接不成功

二 原因

網上查詢得到原因:在mysql8之前的版本中加密規則為mysql_native_password,而在mysql8以后的加密規則為caching_sha2_password

確認docker鏡像創建容器的mysql為mysql8之后的版本

三 解決方案

將mysql的加密規則改回來

grant all on *.* to 'root'@'%';  # 授權

flush privileges;

alter user 'root'@'localhost' identified by '123456' password expire never;  # 修改加密規則

ALTER USER 'root'@'%' IDENTIFIED WITH mysql_native_password BY '123456';  # 修改密碼

flush privileges;

連接成功


免責聲明!

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



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