zoukankan      html  css  js  c++  java
  • Tomcat启动报:The Server time zone value 'XXXXX' 乱码问题解决

    今天给自己项目打包到服务器发布时,运行时,发现报

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

    错误

    经过查询资料发现是

    MySql本身的时区设置的问题导致的


    解决办法:

    方法一:

    1.在mysql安装位置下找到my.ini文件;

    2.修改my.ini文件中:在[mysqld]下方,添加

    default-time-zone='+08:00'

    3.重启即可

    方法二:

    我是springboot项目,使用tomcat发布时报的,可以使用一下方法解决

    在你项目的数据库配置url位置,后面加上 serverTimezone=UTC

    jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=UTF-8&useJDBCCompliantTimezoneShift=true&useLegacyDatetimeCode=false&serverTimezone=UTC

    如果发现新加数据比当前时间少8个小时,或者查询显示出来的数据比数据库入库的时间多8个小时,可以改为:serverTimezone=GMT%2B8

    这样新添加的数据为正常时间


    结束

  • 相关阅读:
    数据挖掘相关资料收集(持续更新)
    常见面试之机器学习算法思想简单梳理
    在c中保存状态
    lua 和 c
    lua 基础库
    lua 面向对象
    lua 高级
    lua 基础
    lua中的协程
    cocos2d中的可见性检测
  • 原文地址:https://www.cnblogs.com/zktww/p/11401048.html
Copyright © 2011-2022 走看看