mysql 連線池 不夠用問題

NO IMAGE

原因: (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)
[[email protected] export]# more yoon.txt 
kill 40;
批量刪除會話:
mysql> source /export/yoon.txt

(3) 配置mysql最大連線數

       這 種方式說來很簡單,只要修改MySQL配置檔案my.ini 或 my.cnf的引數max_connections,將其改為max_connections=1000,然後重啟MySQL即可。