根据 MySQL 状态优化 ---- 2. 连接数

查看 MySQL 服务器运行的各种状态值:

mysql> show global status;

2. 连接数

查看设置的最大连接数:

mysql> show  variables like 'max_connections';
+-----------------+-------+
| Variable_name   | Value |
+-----------------+-------+
| max_connections | 256   |
+-----------------+-------+
1 row in set (0.04 sec)

查看过去的最大连接数:

mysql> show global status like 'Max_used_connections';
+----------------------+-------+
| Variable_name        | Value |
+----------------------+-------+
| Max_used_connections | 245   |
+----------------------+-------+
1 row in set (0.00 sec)

由于 245<256 所以应该不会出现1040错误(MySQL: ERROR 1040:Too many connections)

比较理想的设置是:

Max_used_connections / max_connections * 100% ≈ 85%

若该值在 10% 下,则说明 MySQL 连接数的上限设置过高了。

posted on 2016-07-01 13:59  刘[小]倩  阅读(308)  评论(0编辑  收藏  举报

导航