zoukankan      html  css  js  c++  java
  • Mysql连接异常解决方法

    1、解决:Caused by: com.mysql.cj.exceptions.InvalidConnectionAttributeException: The server time zone valu

    报错信息为:

    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:59)
        at com.mysql.cj.exceptions.ExceptionFactory.createException(ExceptionFactory.java:83)
        at com.mysql.cj.util.TimeUtil.getCanonicalTimezone(TimeUtil.java:128)
        at com.mysql.cj.protocol.a.NativeProtocol.configureTimezone(NativeProtocol.java:2201)
        at com.mysql.cj.protocol.a.NativeProtocol.initServerSession(NativeProtocol.java:2225)
        at com.mysql.cj.jdbc.ConnectionImpl.initializePropsFromServer(ConnectionImpl.java:1391)
        at com.mysql.cj.jdbc.ConnectionImpl.connectOneTryOnly(ConnectionImpl.java:993)
        at com.mysql.cj.jdbc.ConnectionImpl.createNewIO(ConnectionImpl.java:852)
        ... 17 more



    此问题为时区问题,在 JDBC 的连接 url 部分加上 serverTimezone=UTC 即可。 

    spring:
      application:
        name: test
      liquibase:
        enabled: false
      datasource:
          driver-class-name: com.mysql.jdbc.Driver
          url: jdbc:mysql://127.0.0.1:3306/activiti?useUnicode=true&characterEncoding=utf-8&allowMultiQueries=true&serverTimezone=UTC
          username: root
          password: passwd
    


    如图: 

    2、连接mysql 出现:java.sql.SQLException: Unable to load authentication plugin 'caching_sha2_password'. 

    网上查资料说的是mysql5.x 版本和 8.x版本的区别;

    5.7版本是:default_authentication_plugin=mysql_native_password

    8.x版本就是:default_authentication_plugin=caching_sha2_password
    --------------------- 

    mysql驱动已经更新适配了caching_sha2_password 的密码规则,升级到最新版本就可以了。

    改为 :

    <version>8.0.11</version>

    重新启动java 服务器,连接成功。

    正因为当初对未来做了太多的憧憬,所以对现在的自己尤其失望。生命中曾经有过的所有灿烂,终究都需要用寂寞来偿还。
  • 相关阅读:
    关于获取多个id的用法
    纯css打造凹进与突出效果
    ie8兼容半透明效果css
    常用函数积累
    ie兼容图片缩小后模糊失真(锯齿)问题
    图片放大_css3
    弹出层跳出原框架
    ifame_自适应高度
    POJ #2479
    SPOJ #752. Power it!
  • 原文地址:https://www.cnblogs.com/candlia/p/11919998.html
Copyright © 2011-2022 走看看