mysql 报错 too many connections 或者 waiting in connection_control plugin

分析
原因1.
数据库打开文件数超过linux默认打开文件
数量1024 ulimit -a
查看openfiles数量

原因2.
用户名或密码错误,不停连接,默认mysql连接数被耗尽.
根因:链接异常(用户名密码错误)导致connectioncontrol 插件进行拦截,拦截用户身份验证处于 “waiting in connection_control plugin”的链接延迟状态
规避:修改connection_control 插件配置参数
在这里插入图片描述
上图参数含义:连续失败次数3和超过失败连接上限后的最小延迟登录时间为1分;
修改mysql配置文件 /my.cnf

a.connection_control_failed_connections_threshold 表示连接次数,超过此次数则会进入等待。
如果修改为0,则表示禁止链接失败的链接并且不会进入waiting状态
b.connection_control_min_connection_delay 表示等待时间,单位是毫秒。

原因3.
假如:用户名和密码正确,但是链接mysql的驱动jar不存在(未授权使用ssl的话)。程序自动链接尝试机制未关闭,就会导致将原因2现象

根因分析:mysql5.7以后版本中使用ssl验证登录,商用需要授权.

在JDBC连接Mysql数据库的过程中出现了如下的警告信息:

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.

是Mysql数据库的SSL连接问题,提示警告不建议使用没有带服务器身份验证的SSL连接,是在MYSQL5.5.45+, 5.6.26+ and 5.7.6+版本中才有的这个问题。解决办法在警告中已经说明了:

解决办法1:在数据库连接的url中添加useSSL=false;2.url中添加useSSL=true,并且提供服务器的验证证书。如果只是做一个测试的话,没必要搞证书那么麻烦啦,在连接后添加一个useSSL=false即可.
解决办法2:代码中修改

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值