JDBC获取连接Mysql时的时区错误问题

JDBC获取连接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.
解决方法:
1.使用root用户登录mysl(Dos或者MySQL Workbench)
2.输入sql语句(show variables like ‘%time_zone%’;)查询当前的时区配置,如图:
JDBC获取连接Mysql时的时区错误问题)
3.输入sql修改时区(set global time_zone=’+8:00’;)ps:我们为北京时间东八区。如图:
JDBC获取连接Mysql时的时区错误问题

4.Dos下的解决,如图:
JDBC获取连接Mysql时的时区错误问题