查看当前MySQL 链接数 connected
SHOW STATUS LIKE 'Threads%'
Threads_connected显示的数值就是当前的连接数
查看MySQL系统最大链接数 max_connections
show variables like '%max_connections%'
该参数设置过小的最明显特征是出现”Too many connections”错误;
全局每个用户最大连接数 max_user_connections
show variables like 'max_user_connections'
默认情况值为 0。代表:不限制用户资源的。
设置全局每个用户最大连接数
set global max_user_connections=1
响应的连接数 max_used_connections
show variables like 'max_connections' 最大连接数
show status like 'max_used_connections'响应的连接数。
mysql> show variables like ‘max_connections‘;
+-----------------------+-------+
| Variable_name | Value |
+-----------------------+-------+
| max_connections | 256 |
+-----------------------+-------+
mysql> show status like ‘max_used_connections‘;
+-----------------------+-------+
| Variable_name | Value |
+----------------------------+-------+
| max_used_connections | 256|
+----------------------------+-------+
max_used_connections / max_connections * 100%(理想值≈ 85%)
如果max_used_connections跟max_connections相同,那么就是max_connections设置过低或者超过服务器负载上限了,低于10%则设置过大。