阿里云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;
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中的integer 数据类型
- MySQL存储过程
- mysql中int、bigint、smallint 和 tinyint的区别与长度
- mysql load data 导出、导入 csv
- source命令执行SQL脚本文件
- MySQL创建用户及权限控制
- MySQL管理数据表
- linux下mysql添加用户
- mysql procedure
- mysql触发器
- MySQL 备份和恢复策略
- mac下安装mysql(转载)
- mysql 修改编码 Linux/Mac/Unix/通用(杜绝修改后无法启动的情况!)
- MySQL数据的导出、导入(mysql内部命令:mysqldump、mysql)
- mysql数据行转列
- Linux下修改MySQL编码的方法
- MySQL Server 日志
- MySQL 安全事宜
- MySQL 备份与恢复