In a Spring boot project, when connecting to MySQL encounters the ” Establishing SSL connection without server’s identity verification is not recommended” error. The error message as following:

Wed Mar 18 11:53:14 CST 2020 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

The connection properties as:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/springboot
spring.datasource.username=root
spring.datasource.password=88888888

The version of MySQL is

Server version: 8.0.18 MySQL Community Server - GPL

Solution

The solution to fix “Establishing SSL connection without server’s identity verification is not recommended” is add useSSL=false in the URL, like this:

spring.datasource.driver-class-name=com.mysql.cj.jdbc.Driver
spring.datasource.url=jdbc:mysql://127.0.0.1:3306/springboot?useSSL=false
spring.datasource.username=root
spring.datasource.password=88888888