Bitbucket fails to start with Unknown system variable 'query_cache_size' when connecting to MySQL v8+
Platform Notice: Data Center Only - This article only applies to Atlassian apps on the Data Center platform.
Note that this KB was created for the Data Center version of the product. Data Center KBs for non-Data-Center-specific features may also work for Server versions of the product, however they have not been tested. Support for Server* products ended on February 15th 2024. If you are running a Server product, you can visit the Atlassian Server end of support announcement to review your migration options.
*Except Fisheye and Crucible
Summary
Whey trying to connect to a MySQL 8.0.11+ database, the connection fails.
When starting Bitbucket having upgraded MySQL to v8.0.11+, Bitbucket fails to start.
Environment
MySQL v8.0.11+
Connector v 5.1.42 or earlier
Diagnosis
The following appears in the logs
ERROR [spring-startup] com.zaxxer.hikari.pool.HikariPool bitbucket - Exception during pool initialization.
java.sql.SQLException: Unknown system variable 'query_cache_size'
at com.mysql.jdbc.SQLError.createSQLException(SQLError.java:964)
at com.mysql.jdbc.MysqlIO.checkErrorPacket(MysqlIO.java:3973)
...
Cause
The query cache has been removed from the server since MySQL v8.0.3. The connector that supports this has to be version 5.1.43+ (see Connector 5.1.43 release notes)
Solution
Download the latest 5.1.x connector from https://downloads.mysql.com/archives/c-j/
Copy the mysql-connector-java-5.1.XX-bin.jar file from the extracted directory to your
<Bitbucket home directory>/libdirectory (for Bitbucket Server 2.1 or later).Stop, and then restart Bitbucket Server. See Start and stop Bitbucket.
Was this helpful?