mysql8报错解析

1. 场景描述

想把测试数据导一份到本地使用,乱入装了mysql8,使用springboot项目启动的时候报:

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:129) ~[mysql-connector-java-8.0.15.jar:8.0.15]
    at com.mysql.cj.jdbc.exceptions.SQLError.createSQLException(SQLError.java:97) ~[mysql-connector-java-8.0.15.jar:8.0.15]

2.解决方案

在jdbc连接上增加参数配置:&serverTimezone=GMT%2B8

spring.datasource.url=jdbc:mysql://localhost:3306/shiro?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT%2B8

增加的是时区设置,至于为什么是GMT%2B8,据说是为了解析不乱码,不纠结。


I’m 「软件老王」,如果觉得还可以的话,关注下呗,后续更新秒知!欢迎讨论区、同名公众号留言交流!

上一篇:Idea数据库引入异常:java.sql.SQLException: The server time zone value ‘Öйú±ê׼ʱ¼ä‘ is unrecognized


下一篇:WEB项目运行时,多次遇到 The server time zone value 'Öйú±ê׼ʱ¼ä' is unrecognized or represents more