java踩坑之mysql时区与系统不同步问题

数据库连接错误:

Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone value 'Öйú±ê׼ʱ¼ä' 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.

原因:

mysql数据的系统时间具有差异。

解决方案:

mysql> set global time_zone='+8:00';
Query OK, 0 rows affected (0.01 sec)

将数据库全局时区时间+8即可。

posted @ 2020-08-11 17:57  wigginess  阅读(296)  评论(0编辑  收藏  举报