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

mysql 连接池 不够用问题

2017-01-09 18:30 393 查看
原因: (1)连接后没有关闭(2)死锁(3)程序重开的连接数太多等

解决 :

(1)连接后如果不用及时关闭,

(2)手动关闭不用连接

mysql> show processlist;
+----+------+-----------+--------------------+---------+------+-------+------------------+
| Id | User | Host      | db                 | Command | Time | State | Info             |
+----+------+-----------+--------------------+---------+------+-------+------------------+
| 37 | root | localhost | information_schema | Query   |    0 | NULL  | show processlist |
| 38 | root | localhost | NULL               | Sleep   |  559 |       | NULL             |
+----+------+-----------+--------------------+---------+------+-------+------------------+

mysql> kill 40;
1 row in set (0.00 sec)

mysql> use information_schema

mysql> select id from processlist;
+----+
| id |
+----+
| 40 |
+----+
1 row in set (0.00 sec)

mysql> select concat('kill ',id,';') from information_schema.processlist where user='root' into outfile '/export/yoon.txt';
Query OK, 1 row affected (0.09 sec)

[root@db01 export]# more yoon.txt
kill 40;

批量删除会话:
mysql> source /export/yoon.txt


(3) 配置mysql最大连接数

这 种方式说来很简单,只要修改MySQL配置文件my.ini 或 my.cnf的参数max_connections,将其改为max_connections=1000,然后重启MySQL即可。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: