JDBC Mysql8.0报错The server time zone value ‘?й???is unrecognized or represents more than one time z

    技术2026-02-07  1

    is unrecognized or represents more than one time zone. You must configure either the server 。。。

    这个报错是时区的问题,解决的办法有两种,一种是去mysql中 SET GLOBAL time_zone = '+8:00' 即把时区改为东八区。

    或者是在jdbc的链接串中,带上如下信息 "jdbc:mysql://localhost/db?useUnicode=true&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC"

    其中useLegacyDatetimeCode默认开启,关闭后时区相关信息会失效。

    Processed: 0.035, SQL: 9