Mysql连接数

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
#查询当前连接数
show status like 'Threads_connected';
#查询最大连接数
show variables like 'max_connections';
#修改最大连接数
方法一 [即时生效] 需要root权限
set GLOBAL max_connections = 200;
方法二 修改my.cnf文件
max_connections = 200
注: 最大连接数5.7版上限100000
#查看连接信息 root用户可以看到所有连接信息,普通用户只能看到自己的连接信息
show processlist;
show processlist只能列出100条,如果要全列出使用 show full processlist
+----+------+-----------------+--------+---------+------+----------+-----------------------+
| Id | User | Host | db | Command | Time | State | Info |
+----+------+-----------------+--------+---------+------+----------+-----------------------+
| 7 | root | localhost:62599 | sakila | Sleep | 13 | | NULL |
| 8 | root | localhost:62600 | NULL | Sleep | 53 | | NULL |
| 12 | root | localhost | NULL | Query | 0 | starting | show full processlist |
+----+------+-----------------+--------+---------+------+----------+-----------------------+