查看当前数据库连接
+--------+------+----------------------+----------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+--------+------+----------------------+----------+---------+------+-------+------------------+
| 938233 | root | xxx.xx.xxx.xxx:20503 | aaaaaaaa | Sleep | 446 | | |
| 938234 | root | xxx.xx.xxx.xxx:20504 | aaaaaaaa | Sleep | 446 | | |
| 938235 | root | xxx.xx.xxx.xxx:20505 | aaaaaaaa | Sleep | 446 | | |
| 938236 | root | xxx.xx.xxx.xxx:20506 | aaaaaaaa | Sleep | 446 | | |
| 938237 | root | xxx.xx.xxx.xxx:20507 | aaaaaaaa | Sleep | 423 | | |
| 938259 | root | localhost | | Query | 0 | | show processlist |
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
修改最大连接数
在mysql的配置文件中添加以下参数
max_connections = 1000
重启mysql即可
>mysqladmin -uroot -pxxxxx processlist
+--------+------+----------------------+----------+---------+------+-------+------------------+
| Id | User | Host | db | Command | Time | State | Info |
+--------+------+----------------------+----------+---------+------+-------+------------------+
| 938233 | root | xxx.xx.xxx.xxx:20503 | aaaaaaaa | Sleep | 446 | | |
| 938234 | root | xxx.xx.xxx.xxx:20504 | aaaaaaaa | Sleep | 446 | | |
| 938235 | root | xxx.xx.xxx.xxx:20505 | aaaaaaaa | Sleep | 446 | | |
| 938236 | root | xxx.xx.xxx.xxx:20506 | aaaaaaaa | Sleep | 446 | | |
| 938237 | root | xxx.xx.xxx.xxx:20507 | aaaaaaaa | Sleep | 423 | | |
| 938259 | root | localhost | | Query | 0 | | show processlist |
+--------+------+----------------------+----------+---------+------+-------+------------------+
可以看到当前数据库连接信息,那个数据库连接数多。
>show variables like 'max_connections';
+-----------------+-------+
| Variable_name | Value |
+-----------------+-------+
| max_connections | 151 |
+-----------------+-------+
修改最大连接数
在mysql的配置文件中添加以下参数
max_connections = 1000
重启mysql即可