小工具知识网

当前位置: 首页 > 行业知识 > java.sql.SQLException: Unable to load authentication plugin ‘caching

行业知识

java.sql.SQLException: Unable to load authentication plugin ‘caching

2026-12-04 10:06:43 来源:互联网转载

最近遇到了 java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'.这个报错。

主要原因8.x版本的验证模块和之前版本不同:

5.x版本是:default_authentication_plugin=mysql_native_password

8.x版本就是:default_authentication_plugin=caching_sha2_password

 

解决方案

①更新mysql驱动的jar版本,修改为8.0.11版本

    mysql    mysql-connector-java    8.0.11

②修改数据库配置driver为com.mysql.cj.jdbc.Driver(可以不改),url加上serverTimezone=UTC(这两个是8.x与5.x不同的配置)

上一篇:服务器怎么敲命令框框打开?

下一篇:轻松设置邮箱自动回复,简单几步轻松搞定!