How to fix server time zone causing exception when trying to connect to MySQL instance with DataGrip?

ahsteele picture ahsteele · Apr 25, 2019 · Viewed 8k times · Source

When attempting to connect to a MySQL instance with DataGrip I am receiving a com.mysql.cj.exceptions.InvalidConnectionAttributeException exception:

The server time zone value 'XXX' 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 specifc time zone value if you want to utilize time zone support.

Where XXX is my server's timezone (I also love the typo in the exception specifc). This error prevents me from creating a connection to the MySQL server. What is causing this issue?

Answer

ahsteele picture ahsteele · Apr 25, 2019

Your server's time zone is not specific. To get around this you need to set the serverTimezone property to a value that is specific. The simplest choice is to set it to UTC under the Advanced tab:

Advanced Tab serverTimeZone set

To be clear I'm not sure of the ramifications of this, but it did allow me to connect.