java.sql.SQLException: The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more than one time zone.

连接mysql数据库查询数据报错,错误信息如下:

java.sql.SQLException: 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.

错误原因:time zone 时区错误。

1.使用root账户登录mysql,打开命令框。

在test数据右键选择命令列界面。输入 show variables like '%time_zone%';

2.SYSTEM是系统默认美国时间,而我们国家比它们国家晚8个小时,所以需要将时区设置为当前系统时区的时间即可。

输入  set global time_zone='+8:00';

3.再次查看 输入 show variables like '%time_zone%';

4.设置成功,数据库查询数据成功亲测有效

参考博客:https://blog.csdn.net/it_zhang_pg/article/details/86152075

原文地址:https://www.cnblogs.com/ming-blogs/p/10836212.html