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时区不匹配。
解决方法1
mysql配置时,在url中指定时区:
spring.datasource.url=jdbc:mysql://localhost:3306/test?characterEncoding=UTF-8&serverTimezone=GMT%2B8
解决方法2
在mysql中运行命令:
-- 查看当前时区
show variables like '%time_zone%';
-- 设置时区为 东八区
set global time_zone='+8:00';