数据库异常

MySQL

连接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.

解决步骤

  • 连接数据库的url上添加serverTimeZone=Asia/Shanghai
spring.datasource.url=jdbc:mysql://127.0.0.1/test?useUnicode=true&characterEncoding=UTF-8&serverTimeZone=Asia/Shanghai
  • 使用root用户登录mysql
  • 输入sql修改当前时区配置,修改为中国时区
set global time_zone='+8:00';

你可能感兴趣的:(迫于生计的Java旅程)