前两天跑得好好的项目突然报错了,登上服务器查找日志发现出现了很多 Public Key Retrieval is not allowed 报错。
上网一查,发现是jdbc数据库连接字符串的配置问题,添加如下参数即可:
allowPublicKeyRetrieval=true
完成的jdbc连接串如下:
spring: datasource: url: jdbc:mysql://localhost:3306/database_name?serverTimezone=GMT%2b8&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true username: xxxxxx password: xxxxxx
我使用的mysql版本:
mysql Ver 8.0.32-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu))
报错详细信息如下:
2023-07-12 00:31 +08:00: 2023-07-12 00:31:21.959 ERROR 489124 --- [eate-1383444346] com.alibaba.druid.pool.DruidDataSource : create connection SQLException, url: jdbc:mysql://localhost:3306/muning?serverTimezone=GMT%2b8&useSSL=false&characterEncoding=UTF-8&serverTimezone=Asia/Shanghai, errorCode 0, state 08001 2023-07-12 00:31 +08:00: 2023-07-12 00:31 +08:00: java.sql.SQLNonTransientConnectionException: Public Key Retrieval is not allowed 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:110) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:122) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:824) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.ConnectionImpl.<init>(ConnectionImpl.java:444) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.ConnectionImpl.getInstance(ConnectionImpl.java:237) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.NonRegisteringDriver.connect(NonRegisteringDriver.java:198) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1657) ~[druid-1.2.8.jar!/:1.2.8] 2023-07-12 00:31 +08:00: at com.alibaba.druid.pool.DruidAbstractDataSource.createPhysicalConnection(DruidAbstractDataSource.java:1723) ~[druid-1.2.8.jar!/:1.2.8] 2023-07-12 00:31 +08:00: at com.alibaba.druid.pool.DruidDataSource$CreateConnectionThread.run(DruidDataSource.java:2838) ~[druid-1.2.8.jar!/:1.2.8] 2023-07-12 00:31 +08:00: Caused by: com.mysql.cj.exceptions.UnableToConnectException: Public Key Retrieval is not allowed 2023-07-12 00:31 +08:00: at jdk.internal.reflect.GeneratedConstructorAccessor45.newInstance(Unknown Source) ~[na:na] 2023-07-12 00:31 +08:00: at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) ~[na:na] 2023-07-12 00:31 +08:00: at java.base/java.lang.reflect.Constructor.newInstance(Constructor.java:490) ~[na:na] 2023-07-12 00:31 +08:00: at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.protocol.a.authentication.CachingSha2PasswordPlugin.nextAuthenticationStep(CachingSha2PasswordPlugin.java:130) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.protocol.a.authentication.CachingSha2PasswordPlugin.nextAuthenticationStep(CachingSha2PasswordPlugin.java:49) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.protocol.a.NativeAuthenticationProvider.proceedHandshakeWithPluggableAuthentication(NativeAuthenticationProvider.java:447) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.protocol.a.NativeAuthenticationProvider.connect(NativeAuthenticationProvider.java:212) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.protocol.a.NativeProtocol.connect(NativeProtocol.java:1429) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.NativeSession.connect(NativeSession.java:133) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:944) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:814) ~[mysql-connector-j-8.0.32.jar!/:8.0.32] 2023-07-12 00:31 +08:00: ... 6 common frames omitted 2023-07-12 00:31 +08:00:
本站文章除注明转载/出处外,均为原创,若要转载请务必注明出处。转载后请将转载链接通过邮件告知我站,谢谢合作。本站邮箱:admin@only4.work
尊重他人劳动成果,共创和谐网络环境。点击版权声明查看本站相关条款。