出现
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
错误,是数据库的时区问题
解决办法:在你的url后面加上serverTimezone=GMT%2B8
spring.datasource.url = jdbc:mysql://localhost:3306/testdb?useUnicode=true&characterEncoding=UTF8&useSSL=false&serverTimezone=GMT%2B8
设置为北京时间东八区
附:查看时区语句show VARIABLES like "%time_zone%"
解决办法二:
设置mysql的时区
MySQL默认的时区是UTC时区
(1)永久的修改:修改mysql的配置文件,添加:default-time-zone='+08:00',重启mysql生效
(2)临时的修改:执行mysql命令 set global time_zone='+08:00',立即生效,重启mysql后失效
本文详细介绍了如何解决在使用MySQL数据库时遇到的时区错误,包括通过修改连接URL添加serverTimezone参数,以及永久和临时修改MySQL配置文件来设置时区。
790

被折叠的 条评论
为什么被折叠?



