MySQL 8.0 运行项目时,报错 Public Key Retrieval is not allowed 的解决办法
com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed
在数据库的配置文件中(yml,或者properties文件)中配置数据源的位置加上&allowPublicKeyRetrieval=true就可以了
spring:
profiles: dev
datasource:
driver-class-name: com.mysql.cj.jdbc.Driver
username: root
password: mysql
url: jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=UTC&allowPublicKeyRetrieval=true
platform: mysql
schema: classpath:db/schema.sql
data: classpath:db/data.sql
# 每次重启都会根据data.sql schema.sql重建表数据, 设置 NEVER 就不启动重建
# Each restart will rebuild the table data according to data.sql schema.sql
# setting NEVER will not start the reconstruction
initialization-mode: always
jpa:
database: mysql
show-sql: true