问题 :连接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
然后重新启动服务即可!
- MySQLNonTransientConnectionExcept jdbc exceptions Retrieval Publicmysqlnontransientconnectionexcept jdbc exceptions retrieval allowed mysql8 public retrieval allowed public key unabletoconnectexception exceptions retrieval mysqlnontransientconnectionexcept retrieval retrieval-augmented why_retrieval_beats_cramming_ clip-retrieval public