使用JDBC连接MySql时出现:The server time zone value 的问题

tech2024-03-24  17

具体场景:

服务器安装Mysql8.0.20

原来使用的jdbc驱动为mysql5.1,为了更好的性能和匹配度,就改为myql8.0.20jdbc驱动。

更换驱动后要注意修改dirveClassName

原来的低版本驱动名称为:com.mysql.jdbc.Driver

新驱动名称为: jdbc.driverClassName =com.mysql.cj.jdbc.Driver

启动应用,结果在连接数据库过程中出现如下错误:

        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

根据提示信息修改jdbcurl即可:

jdbc.url=jdbc:mysql://127.0.0.1:3308/dbname?useUnicode=true&characterEncoding=utf-8&autoReconnect=true&failOverReadOnly=false&useSSL=false&serverTimezone=UTC

(红色部分为新加参数)

最后重新启动,OK,正常!

最新回复(0)