mysql 8连接配置

先来对比一组配置图:

 

#MySQL 8 配置

driverClassName: com.mysql.cj.jdbc.Driver

url: jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useSSL=false&serverTimezone=UTC

username: root

password: root

#MySQL 5.1.38 配置

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

url: jdbc:mysql://localhost:3306/test?allowMultiQueries=true&useUnicode=true&characterEncoding=UTF-8&useSSL=false

username: root

password: root

 

不同点:

一:

mysql8的 driverClassName 使用的是: com.mysql.cj.jdbc.Driver

低版本的mysql使用的是:com.mysql.jdbc.Driver

这里需要把Mysql的jar包,升级到8.0版本以上

如下:

二:

需要在mysql8的后边加上:

useSSL=false&serverTimezone=UTC

不加的话,活报错,异常信息如下:

CST 2018 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.

你可能感兴趣的:(Java,mysql)