Advertisement

处理MySQL的时区设置问题

阅读量:

一、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驱动程序(使用“serve

全部评论 (0)

还没有任何评论哟~