com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not?

问题 :连接MySQL数据库时抛出异常信息: com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
一开始aplication.yml配置如下所示:

spring:
application:
name: service-provider-sentinel9999
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/gwmdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8
username: root
password: root

 

后来找了一些解决方案,发现是MySQL 8.0版本导致的问题,需要在后面加 allowPublicKeyRetrieval=true,如下所示:

spring:
application:
name: service-provider-sentinel9999
datasource:
driver-class-name: com.mysql.jdbc.Driver
url: jdbc:mysql://localhost:3306/gwmdb?useSSL=false&useUnicode=true&characterEncoding=UTF-8&allowPublicKeyRetrieval=true
username: root
password: root

 

然后重新启动服务即可!

posted @   尐鱼儿  阅读(164)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· winform 绘制太阳,地球,月球 运作规律
· 震惊!C++程序真的从main开始吗?99%的程序员都答错了
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 【硬核科普】Trae如何「偷看」你的代码?零基础破解AI编程运行原理
历史上的今天:
2018-10-30 IBM斥资340亿美元收购红帽
点击右上角即可分享
微信分享提示