7

Data source rejected establishment of connection, message from server: "To...

 3 years ago
source link: https://blog.csdn.net/ljphhj/article/details/23804057
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.
neoserver,ios ssh client

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

这些天一直在弄项目管理的大作业,web程序经常遇到这个问题,但是稍微等会又好好的了,一开始怀疑是没有关闭session,但之后查看了代码,发现主要原因出在数据库的配置上

异常信息:Data source rejected establishment of connection,  message from server: "Too many connections"

可能的原因

1.mysql的max_connections属性配置太小的问题
2.可能是多次insert,update操作没有关闭session。

解决方案:
1.修改tomcat里的session 的wait_timeout时间减少为200
2.对处理量大的对数据库insert或update的操作提供transaction支持.(Spring中配置)

原因:

mysql安装目录下的my.ini(linux: my.cnf)中设定的并发连接数太少或者系统繁忙导致连接数被占满

解决方式:

Windows: 找到mysql的安装目录,打开my.ini文件,找到max_connections配置,默认是100,设置成1000,重启mysql

一定要重新启动MYSQL才能生效

cmd下执行

net stop mysql

net start mysql

Linux: 找到mysql的安装目录,打开my.cnf文件

在[mysqld] 下面添加下面三行

max_connections=1000
max_user_connections=500

wait_timeout=200

//max_connections设置最大连接数为1000

//max_user_connections设置每用户最大连接数为500
//wait_timeout表示200秒后将关闭空闲(IDLE)的连接,但是对正在工作的连接不影响。

//保存退出,并重新启动MySQL

sudo stop mysql

sudo start mysql

//重新启动MySQL后使用下面的命令查看修改是否成功

# mysqladmin -uroot -p variables

Password:

//可以看到以下项说明修改成功

| max_connections                 | 1000

| max_user_connections            | 500

| wait_timeout                    | 200


About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK