连接数据库报错Unable to load authentication plugin caching_sha2_password

报错Exception during pool initialization.

java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.

 

报错与数据库有关的,应该是从MySQL 8.0.4开始, 默认的认证插件从mysql_native_password 变为caching_sha2_password

参考https://dev.mysql.com/doc/refman/8.0/en/caching-sha2-pluggable-authentication.html,创建新用户和密码

参考sql:
CREATE USER 'sha2user'@'localhost'IDENTIFIED WITH caching_sha2_password BY 'password';

 


 

 

root账号修改为caching_sha2_password的任然不行。

 

进入mysql命令行,使用如下命令解决:

ALTER USER 'yourusername'@'localhost' IDENTIFIED WITH mysql_native_password BY 'youpassword';

 

 

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章