springbott配置mysql遇到的问题
2022-08-26 13:37 ly772186472 阅读(42) 评论(0) 收藏 举报
这个一般都是配置问题:
我是mysql配置出问题了 driver-class-name=
spring.datasource.driver=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/db2009_mybaitis_plus?useUnicode=true&characterEncoding=utf8 spring.datasource.username=root spring.datasource.password=123456
正确配置springboot 连接数据库
spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver spring.datasource.url=jdbc:mysql://localhost:3306/db2009_mybaitis_plus?useUnicode=true&characterEncoding=utf8 spring.datasource.username=root spring.datasource.password=123456
问题二:

连接mysql数据源失败
name=com.mysql.cj.jdbc.Driver ---改为
com.mysql.jdbc.Driver
在以前使用com.mysql.jdbc.Driver的时候,导入的是 mysql-connector-java 5
现在使用com.mysql.cj.jdbc.Driver的时候,导入的是 mysql-connector-java 8
问题三:
Fri Aug 26 13:50:23 CST 2022 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

解决方法:
在mysql连接字符串的url中添加配置 ?useSSL=false即可:
useSSL=false 禁用SSL
useServerPrepStmts=true 开启预编译功能
String url = "jdbc:mysql://127.0.0.1:3306/db1?useUnicode=true&characterEncoding=utf-8&useSSL=false";
浙公网安备 33010602011771号