java.sql.SQLException: Wrong time zone

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

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 does not match the time zone.

Workaround 1

When mysql configuration, specifying a time zone in the url:

spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=GMT%2B8

Solution 2

Run the command in mysql:

--  查看当前时区
show variables like '%time_zone%';

-- 设置时区为 东八区
set global time_zone='+8:00';

 

Guess you like

Origin blog.csdn.net/J1014329058/article/details/88529757