mysql istransient_mysql-connector-java之 SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is re...

mysql-connector-java之 SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required异常问题

1 报错信息:

使用spring boot整合项目的时候,遇到了一个异常 ,mybatis与spring整合报错:

019-01-09 10:07:49,224 [Druid-ConnectionPool-Create-12407003] ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url: jdbc:mysql://1.1.1.1:3306/database?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai, errorCode 0, state 08001

java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:526)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:489)

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:72)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1606)

at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:633)

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:347)

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:149)

at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:218)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1470)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1533)

at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2333)

Caused by: com.mysql.cj.core.exceptions.UnableToConnectException: CLIENT_PLUGIN_AUTH is required

at sun.reflect.GeneratedConstructorAccessor119.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)

at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)

at com.mysql.cj.mysqla.io.MysqlaProtocol.rejectConnection(MysqlaProtocol.java:327)

at com.mysql.cj.mysqla.authentication.MysqlaAuthenticationProvider.connect(MysqlaAuthenticationProvider.java:207)

at com.mysql.cj.mysqla.io.MysqlaProtocol.connect(MysqlaProtocol.java:1414)

at com.mysql.cj.mysqla.MysqlaSession.connect(MysqlaSession.java:132)

at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1726)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1596)

... 9 common frames omitted

2019-01-09 10:07:49,725 [Druid-ConnectionPool-Create-12407003] ERROR com.alibaba.druid.pool.DruidDataSource - create connection SQLException, url: jdbc:mysql://1.1.1.1:3306/database?useUnicode=true&characterEncoding=UTF-8&zeroDateTimeBehavior=convertToNull&serverTimezone=Asia/Shanghai, errorCode 0, state 08001

java.sql.SQLNonTransientConnectionException: CLIENT_PLUGIN_AUTH is required

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:526)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:513)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:505)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:479)

at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:489)

at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:72)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1606)

at com.mysql.cj.jdbc.ConnectionImpl.(ConnectionImpl.java:633)

at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:347)

at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:219)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:149)

at com.alibaba.druid.filter.stat.StatFilter.connection_connect(StatFilter.java:218)

at com.alibaba.druid.filter.FilterChainImpl.connection_connect(FilterChainImpl.java:143)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1470)

at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1533)

at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2333)

Caused by: com.mysql.cj.core.exceptions.UnableToConnectException: CLIENT_PLUGIN_AUTH is required

at sun.reflect.GeneratedConstructorAccessor119.newInstance(Unknown Source)

at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:54)

at com.mysql.cj.core.exceptions.ExceptionFactory.createException(ExceptionFactory.java:73)

at com.mysql.cj.mysqla.io.MysqlaProtocol.rejectConnection(MysqlaProtocol.java:327)

at com.mysql.cj.mysqla.authentication.MysqlaAuthenticationProvider.connect(MysqlaAuthenticationProvider.java:207)

at com.mysql.cj.mysqla.io.MysqlaProtocol.connect(MysqlaProtocol.java:1414)

at com.mysql.cj.mysqla.MysqlaSession.connect(MysqlaSession.java:132)

at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:1726)

at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:1596)

... 9 common frames omitted

2

总的原因:mysql 与 mysql-connector-java 与 mybatis 三者版本的不匹配。

2.1 第一种:降低 mysql-connector-java的版本

需要将mysql-connector-java的版本由6.0.6降到5.1.x版本

mysql

mysql-connector-java

6.0.6

但是我降级之后,并没有解决问题。于是看第二种方法:

2.2 第二种升级mysql版本

经过思考和查询相关mysql-connector-java驱动说明,发现驱动和mysql数据库的版本也有关系:

mysql官网驱动版本和数据库版本说明,地址:https://dev.mysql.com/doc/connector-j/8.0/en/connector-j-versions.html

36060baec394f9e70100041d0d18737d.png

由上图可见:mysql-connector-java最低只支持 mysql 5.5 的版本。

我们查看本机的mysql版本:

win+r 打开 cmd 进入到mysql的安装目录下的bin目录,比如:e:\mysql\bin

输入命令:mysql --version

显示:

mysql Ver 14.14 Distrib 5.1.64, for Win64 (x86_64)

果然,我的mysql是2017年装的,太久不用了,已经过了。 经过升级版本到5.7 就解决问题了。

参考:https://my.oschina.net/u/3640994/blog/3000068

参考:https://blog.csdn.net/lamp_yang_3533/article/details/52266320

参考:https://blog.csdn.net/qq_19635589/article/details/80560183

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值