尝试使用 DataGrip 连接到 MySQL 实例时,如何修复导致异常的服务器时区?

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

尝试使用 DataGrip 连接到 MySQL 实例时,我收到 com.mysql.cj.exceptions.InvalidConnectionAttributeException 异常:

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.

其中 XXX 是我服务器的时区(我也喜欢例外 specifc 中的拼写错误)。此错误阻止我创建到 MySQL 服务器的连接。是什么导致了这个问题?

您的服务器时区不明确。要解决此问题,您需要将 serverTimezone 属性 设置为特定的值。最简单的选择是在“高级”选项卡下将其设置为UTC

明确地说,我不确定这会产生什么后果,但它确实让我能够连接。

我遇到了同样的问题,我尝试更换驱动为5.1,连接成功:

在设置中自行设置时区: