~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

开发工具与关键技术:SQLyog Community - 64 bit 

作者:吴业华

撰写时间:2020年10月7号

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

在我使用MySQL8.0搭建javaweb项目时遇到了 idea给我报MySQL了时区的问题

Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: 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.

   at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)

    at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)

    at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)

    at java.lang.reflect.Constructor.newInstance(Constructor.java:423)

    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:61)

    at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:85)

    at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:132)

    at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2234)

    at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2258)

    at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1319)

    at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:966)

   at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:825)

    ... 44 more

然后我们有几种解决的方法:

方法一:

MySQL8.0时区

MySQL8.0时区

set time_zone = "+8:00";

 

set global time_zone = "+8:00";

这两个都可以第一个设置了不行的话再设置第二句代码

方法二:

MySQL8.0时区

    加上这句?serverTimezone=GMT修改时区

然后再次执行项目启动

部署完毕:么么么么么哒

相关文章: