mysql报错 Data source rejected establishment of connection, message from server "too many connections"

1、问题描述

启动服务时没启动成功,查看错误日志,报错如下

Data source rejected establishment of connection, message from server "too many connections"

2、错误原因

Mysql数据库最大连接数设置的太小,导致应用不能创建Mysql数据库连接
查看Mysql数据库最大连接数

SHOW VARIABLES LIKE 'max_connections';

最大连接数是151

在这里插入图片描述
查看应用报错时,Mysql实际连接数 是264,超过mysql设置的最大连接数151。
在这里插入图片描述

3、解决方法

修改mysql配置文件/etc/my.cnf

vi /etc/my.cnf

在最后加入一行

max_connections=10000

然后重启mysql服务

systemctl restart mysqld.service

查看Mysql数据库最大连接数

SHOW VARIABLES LIKE 'max_connections';

最大连接数是9190

在这里插入图片描述

Logo

腾讯云面向开发者汇聚海量精品云计算使用和开发经验,营造开放的云计算技术生态圈。

更多推荐