MySQL8.0 database connection errors and solutions

MySQL8.0 database connection errors and solutions

The use of outdated packages

  1. Error Messages

Loading class com.mysql.jdbc.Driver'. This is deprecated. The new driver class iscom.mysql.cj.jdbc.Driver'. The driver is automatically registered via the SPI and manual loading of the driver class is generally unnecessary

  1. Cause Analysis

    com.mysql.jdbc.Driver outdated, the new class is com.mysql.cj.jdbc.Driver

  2. Solution

    原代码
    Class.forName("com.mysql.jdbc.Driver");
    修改后代码
    Class.forName("com.mysql.cj.jdbc.Driver");
  3. Above all built on the premise that the correct mysql-connector-java driver package (version to be consistent and MySQL version)

    mysql-connector-java driver package Download

Inconsistent zone

  1. Error Messages

java.sql.SQLException: The server time zone value xxxxx is unrecognized or represents more than one time zone.

  1. Cause Analysis

    Inconsistent system time zone and time zone MySQL

  2. Solution

    a. Add the url serverTimezone items, such as

    url="jdbc:mysql://localhost:3306/order_system?serverTimezone=GMT%2B8"(GMT%2B8表示gmt+8时区)

    b.windos Under Settings

    Modify "C: \ ProgramData \ MySQL \ MySQL Server 8.0 \ my.ini" file, add a line at the end of

    default-time_zone='+8:00'

    then

    net stop mysqlxx#停止mysql服务
    net start mysqlxx#开始MySQL服务,说实话这个命令不好使xx数字不是固定的,还要管理员运行
    或者
    右键我的电脑->管理->服务和应用程序->服务->右侧找到MySQL,点击->左侧点击重启动此服务

No SSL server connection acknowledgment

  1. Error Messages

CST 2018 WARN: Establishing SSL connection without server's identity verification is not recommended

  1. Cause Analysis

    No SSL server connection acknowledgment

  2. Solution

    a. In the url tail add? useSSL = false

Guess you like

Origin www.cnblogs.com/redo19990701/p/11892430.html