跳到主要内容

mysql-problem

1、SSL 问题

报错信息:

Thu Feb 02 17:06:57 CST 2023 WARN: Establishing SSL connection without server's identity verification is not recommended. According to MySQL 5.5.45+, 5.6.26+ and 5.7.6+ requirements SSL connection must be established by default if explicit option isn't set. For compliance with existing applications not using SSL the verifyServerCertificate property is set to 'false'. You need either to explicitly disable SSL by setting useSSL=false, or set useSSL=true and provide truststore for server certificate verification.

解决方法:在 url 中添加 &useSSL=false

2、驱动版本问题

报错信息:

Unable to load authentication plugin 'caching_sha2_password'.

问题原因:驱动版本为 5.x.x

解决方法:升级驱动版本至 8.x.x

3、驱动类问题

报错信息:

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

解决方案:

驱动类改为 com.mysql.cj.jdbc.Driver

4、密钥问题

报错信息:

Public Key Retrieval is not allowed

解决方法:url 添加 allowPublicKeyRetrieval=true

5、lower_case_table_names

这个参数在 MySQL8 中只能在数据库安装之前在 /etc/my.cng 中设置,否则只有重新安装一个数据库。

vim /etc/my.cnf
# 添加
lower_case_table_names=1

6、### message from server: "Host 'xxxxx' is blocked because of many connection errors; unblock with 'mysqladmin flush-hosts'"

mysql
-u root -p
-- 执行 sql 语句
mysql> flush hosts;

原因是由于程序中创建了过多的MySQL连接,通常情况下,程序开始的运行的时候建立与数据库的连接,运行期间进行数据库的一些增删改查操作,程序关闭的时候,断开与数据库的连接。