Database migration to MySQL fails - java.sql.SQLException: The server time zone value CDT is unrecognized or represents more than one time zone

Still need help?

The Atlassian Community is here for you.

Ask the community

Platform notice: Server and Data Center only. This article only applies to Atlassian products on the Server and Data Center platforms.

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

Problem

When migrating to an external MySQL database you are presented with this error message:

Unable to connect to MySQL database jdbc:mysql://localhost:3306/<application>:
java.sql.SQLException: The server time zone value 'CDT' is unrecognized or represents more than one time zone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specific time zone value if you want to utilize time zone support. Couldn't connect to the database.

Cause

This is a bug affecting the mysql-connector-java from version 5.1.33 up to 5.1.37: http://bugs.mysql.com/bug.php?id=79343

Workaround

Add the useJDBCCompliantTimezoneShift=trueuseLegacyDatetimeCode=false, and the serverTimezone=UTC to the jdbc url in the $BITBUCKET_HOME/shared/bitbucket.properties file. If this file doesn't exist, create it and ensure it looks similar to this:

jdbc.driver=com.mysql.jdbc.Driver
jdbc.url=jdbc:mysql://localhost:3306/bitbucket?characterEncoding=utf8&useUnicode=true&sessionVariables=storage_engine%3DInnoDB&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC
jdbc.user=<bitbucketuser>
jdbc.password=<your_password_for_the_db>

Replace <bitbucketuser> with the user you set up for Bitbucket Server to access the database and <your_password_for_the_db> with the actual password the bitbucketuser uses to access the database.

If the error persists after a restart of the application, ensure you are using a more recent version of the connector, specifically 5.1.39.

Last modified on Sep 15, 2016

Was this helpful?

Yes
No
Provide feedback about this article
Powered by Confluence and Scroll Viewport.