解决The server time zone value '�й���׼ʱ��' is unrecognized or represents more than one time zone. You ...

解决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 specific time zone value if you want to utilize time zone support.问题

报错信息:

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 specific time zone value if you want to utilize time zone support.

服务器时区值'�й���׼ʱ��' 无法识别或表示多个时区。如果要利用时区支持,必须将服务器或JDBC驱动程序(通过“serverTimezone”配置属性)配置为使用更具体的时区值。

解决方式:

在URL上添加serverTimezone=UTC

String url = "jdbc:mysql://localhost:3306/school?serverTimezone=UTC";

//在Mybatis中
jdbc:mysql://localhost:3306/mybatis?useUnicode=true&characterEncoding=utf8&serverTimezone=GMT

参考:

https://blog.csdn.net/qq_43430011/article/details/114498695

(此链接中汇总了各种MySQL8.0 JDBC可能遇见的问题,非常具有参考价值。感谢。)


版权声明:本文为LYly_B原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接和本声明。