The server time zone value ‘¥x¥_?D·??é??’ 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的连接通常都是:
jdbc:mysql://localhost/blog?useUnicode=true&characterEncoding=utf8
直接指定字符集就行了,今天报了这个错误,找了下原因,是因为时区的问题。
修改url为
jdbc:mysql://localhost/blog?useUnicode=true&characterEncoding=utf8&serverTimezone=UTC
mysql > select CURTIME();
或
mysql > select now();
看当前时间是否正确,可以看到mysql当前使用的是那一个时区的时间。
mysql > SET time_zone = '+8:00'; # 此为北京时,我们所在东8区
mysql> flush privileges; # 立即生效
此时mysql时区已更改正确,与系统时区都使用为 Shanghai时间了。
这种方法好像只能在终端上使用,退出终端后时间又会变成原来的,看来只能重启mysql了。
原文:https://www.cnblogs.com/mengw/p/12213093.html