• 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 服务器,连接成功。

    正因为当初对未来做了太多的憧憬,所以对现在的自己尤其失望。生命中曾经有过的所有灿烂,终究都需要用寂寞来偿还。
  • 相关阅读:
    将IIS中网站日志批量导入到mysql【python】
    Python网站日志分析
    python 获取文件版本号和修改时间
    python将IIS日志导入到SQL
    python2.7 MySQLdb模块在win32下安装
    《python核心编程》课后题第二版第十五章463页
    python批量文件重命名
    python随机生成彩票号码
    python获取IP归属地
    百度收录批量查询【python版】
  • 原文地址:https://www.cnblogs.com/candlia/p/11919998.html
Copyright © 2020-2023  润新知