spring boot mybatis报错: The server time zone value '�й���׼ʱ��' is unrecognized

错误标识

The server time zone value ‘�й���׼ʱ��’ is unrecognized

异常日志:

create connection error, url: jdbc:mysql://localhost:3306/yun?charsetEncoding=utf8&zeroDateTimeBehavior=convertToNull, errorCode 0, state 01S00
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.
at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:545

解决办法:

1、降低mysql连接版本

这个错误是因为mysql配置的依赖包是高版本的情况下出现的:

<dependency>
    <groupId>mysqlgroupId>
    <artifactId>mysql-connector-javaartifactId>
    <version>6.0.6version>
dependency>

配置mysql连接时区

然后配置mysql连接时区,其中UTC是统一标准世界时间。
完整的连接字符串示例:

jdbc:mysql://localhost:3306/test?serverTimezone=UTC

或者还有另一种选择:

jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8,

这个是解决中文乱码输入问题,当然也可以和上面的一起结合:

jdbc:mysql://127.0.0.1:3306/test?useUnicode=true&characterEncoding=UTF-8&serverTimezone=UTC

你可能感兴趣的:(spring boot mybatis报错: The server time zone value '�й���׼ʱ��' is unrecognized)