编程访问Mysql数据库时,报出错误如下,为时区错误:
The server time zone value 'xxxxxxx' is unrecognized or represents more than one time zone
两种解决方法:
(1)在数据库连接语句后添加?serverTimezone=UTC,注意,该语句需要跟在数据库连接语句的第一个位置,否则会报错,例如:
jdbc.url=jdbc:mysql://localhost:3306/testdatabase?serverTimezone=UTC&useUnicode=true&characterEncoding=utf-8
(2)修改Mysql的时区为东8区,Navicat执行如下命令:
set global time_zone='+8:00';