您的位置:首页 > 数据库 > MySQL

阿里云RDS报错:Too many connections

2016-06-03 14:23 453 查看
在使用虚拟主机过程中,如果应用程序连接mysql的连接数过多,会导致网页程序报如下错误:
Can not connect to MySQL server
Error: Too many connections
此问题的原因是由于程序没有及时释放mysql数据库连接,连接数堆积、变满,导致新的连接无法连接到mysql。
1.查看数据库的最大连接数:
mysql>show variables like '%max_connections%';
+-------------------------+-----------------+
| Variable_name | Value
+-------------------------+-----------------+
| extra_max_connections | |
| max_connections | 110 |
+-------------------------+-----------------+
共返回 2 行记录,花费 121.61 ms.
2.查看连接数据库IP的连接数:
mysql>select SUBSTRING_INDEX(host,':',1) as ip , count(*) from information_schema.processlist group by ip;
+----------------+--------------------+
| ip | count(*) |
+----------------+--------------------+
| 110.110.10.110 | 1 |
| 110.110.10.111 | 3 |
| 110.110.10.112 | 2 |
| 110.110.10.113 | 1 |
| 110.110.10.114 | 2 |
| 110.110.10.115 | 10 |
| 110.110.10.116 | 2 |
+----------------+--------------------+
共返回 7 行记录,花费 69.87 ms.
3.查看当前数据库连接状态:
mysql>show full processlist;
4.kill掉ID持续时间很长的连接
mysql>kill 35007306;
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql RDS