MySQL: JDBC connection MySQL error Unknown system variable 'query_cache_size'

1. Mito

Here Insert Picture Description

2. Background

After connecting Mysql reported the following error message after the unit testing today:

20/04/07 20:39:00 INFO AppInfoParser: Kafka version : 0.10.0.1
20/04/07 20:39:00 INFO AppInfoParser: Kafka commitId : a7a17cdec9eaa6c5
java.sql.SQLException: Unknown system variable 'query_cache_size'
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:569)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:537)
	at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:527)
	at com.mysql.cj.jdbc.exceptions.SQLExceptionsMapping.translateException(SQLExceptionsMapping.java:115)
	at com.mysql.cj.jdbc.ConnectionImpl.execSQL(ConnectionImpl.java:2011)

The reason is that the online search mysql-connecter-java version is too low, it is clear that the database drivers and database versions do not correspond

Solution:

As mybatis mysql-5.1.14 using the driver, and the data source connections arranged mybatis is mysql-8.0.11, pom file to modify, as follows:

<dependency>
    <groupId>mysql</groupId>
    <artifactId>mysql-connector-java</artifactId>
    <version>8.0.11</version>
</dependency>

According to the official statement is:

The query cache is deprecated as of MySQL 5.7.20, and is removed in 
MySQL 8.0. Deprecation includes query_cache_size.

Means that the query cache in MySQL5.7.20 already out of date, and after MySQL8.0 has been removed.

I changed 8.0.11 on it.

Released 1199 original articles · won praise 457 · Views 1.53 million +

Guess you like

Origin blog.csdn.net/qq_21383435/article/details/105374985