前后端分离爬坑 - Druid连接池报错:create connection SQLException

5,287 阅读1分钟

本地环境:

1.本地MySQL版本为8.0.1

2.MySQL驱动为新版

报错详情

com.alibaba.druid.pool.DruidDataSource - create connection SQLException, com.mysql.jdbc.exceptions.jdbc4.MySQLNonTransientConnectionException: Public Key Retrieval is not allowed

Public Key Retrieval is not allowed

解决方案

更换mysql驱动

    driver-class-name: com.mysql.cj.jdbc.Driver

Url后面加上allowPublicKeyRetrieval=true

url: jdbc:mysql://localhost:3306/test?characterEncoding=utf8&useSSL=false&serverTimezone=UTC&rewriteBatchedStatements=true&allowPublicKeyRetrieval=true