一、MySQL 5.5.6版本
url 中不论加不加serverTimezone属性,返回的时间都会少8小时,相当于后面测试中的第二种情况,默认时区为东八区。
二、MySQL 8.0.20版本
url中必须添加serverTimezone属性,否则进行sql操作时会报如下的错:
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 specific time zone value if you want to utilize time zone support.
服务器时区值’。©���ʱ��’无法识别或代表多个时区。如果要利用时区支持,则必须配置服务器或JDBC驱动程序(通过“ serverTimezone”配置属性)以使用更特定的时区值。