Skip to content

Instantly share code, notes, and snippets.

@scodx
Created May 16, 2019 14:49
Show Gist options
  • Save scodx/d241b6b803222c70c3dff48b0f999aa6 to your computer and use it in GitHub Desktop.
Save scodx/d241b6b803222c70c3dff48b0f999aa6 to your computer and use it in GitHub Desktop.
MySQL connection refused, happened on PHPStorm and Datagrid

Background

If you are using a java app that tries to connect to a MySQL/MariaDB database and gets this error:

java.sql.SQLException: The server timezone value 'UTC' is unrecognized or represents more than one timezone. You must configure either the server or JDBC driver (via the serverTimezone configuration property) to use a more specifc timezone value if you want to utilize timezone support.

it seems that the app is not sending the correct timezone params, you might want to add this to the connection string:

jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

Note that just passing serverTimezone=UTC fixed the problem, but it might require the other params.

Datagrid

With datagrid I was getting another connection error, that it tried to connect 3 times and the server didn't respond, I applied the same fix and it worked

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment