mysql错误:java.sql.SQLException: The server time zone value '�й���׼ʱ��' is unrecognized or ...

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.java

 

 

 这是SpringBoot整合MySQL的依赖包版本太高,在高版本的MySQL依赖中数据库和系统时区差别所形成的。系统为SQL默认美国时间,而咱们中国要比他们迟8小时,所以将时区设置为当前系统时区便可,采用+8:00格式mysql

 

两种解决方案sql

1.下降 mysql-connector-java依赖版本 (使用5.1.x版本便可)数据库

<dependency>
  <groupId>mysql</groupId>
  <artifactId>mysql-connector-java</artifactId>
  <version>5.1.35</version>
</dependency>

2.在JDBC链接url后添加时区属性:url

&serverTimezone=GMT%2B8spa

相关文章
相关标签/搜索