MySQL,查看连接数和状态等

1、mysql> show status like '%connect%';

   Connections,试图连接到(不管是否成功)MySQL服务器的连接数。
   Max_used_connections,服务器启动后已经同时使用的连接的最大数量。
   Threads_connected,当前的连接数。

2、mysql> show variables like '%connect%';

   max_connections,最大连接数。

3、修改max_connections

   在配置文件(my.cnf或my.ini)在最下面,天加一句:
   max_connections=32000
   然后,用命令重启:/etc/init.d/mysqld restart
   虽然这里写的32000,
实际MySQL服务器允许的最大连接数16384;
   添加了最大允许连接数,对系统消耗增加不大。

4、mysql> show processlist;
显示当前正在执行的MySQL连接。

mysql> show status like '%connect%';
+-----------------------------------------------+---------+
| Variable_name                                 | Value   |
+-----------------------------------------------+---------+
| Aborted_connects                              | 45643   |
| Connection_errors_accept                      | 0       |
| Connection_errors_internal                    | 0       |
| Connection_errors_max_connections             | 2275689 |
| Connection_errors_peer_address                | 15      |
| Connection_errors_select                      | 0       |
| Connection_errors_tcpwrap                     | 0       |
| Connections                                   | 145379  |
| Max_used_connections                          | 152     |
| Performance_schema_session_connect_attrs_lost | 0       |
| Ssl_client_connects                           | 0       |
| Ssl_connect_renegotiates                      | 0       |
| Ssl_finished_connects                         | 0       |
| Threads_connected                             | 7       |
+-----------------------------------------------+---------+
14 rows in set (0.00 sec)

mysql> show variables like '%connect%';
+-----------------------------------------------+-----------------+
| Variable_name                                 | Value           |
+-----------------------------------------------+-----------------+
| character_set_connection                      | utf8            |
| collation_connection                          | utf8_general_ci |
| connect_timeout                               | 10              |
| disconnect_on_expired_password                | ON              |
| init_connect                                  |                 |
| max_connect_errors                            | 100             |
| max_connections                               | 151             |
| max_user_connections                          | 0               |
| performance_schema_session_connect_attrs_size | 512             |
+-----------------------------------------------+-----------------+
9 rows in set (0.00 sec)

mysql> show processlist;
+--------+------+-----------------+------+---------+------+-------+------------------+
| Id     | User | Host            | db   | Command | Time | State | Info             |
+--------+------+-----------------+------+---------+------+-------+------------------+
| 145367 | root | localhost       | NULL | Query   |    0 | init  | show processlist |
| 145373 | root | localhost:58275 | push | Sleep   |  179 |       | NULL             |
| 145374 | root | localhost:58276 | push | Sleep   |  179 |       | NULL             |
| 145375 | root | localhost:58278 | push | Sleep   |  179 |       | NULL             |
| 145376 | root | localhost:58280 | push | Sleep   |    0 |       | NULL             |
| 145377 | root | localhost:58279 | push | Sleep   |    2 |       | NULL             |
| 145378 | root | localhost:58282 | push | Sleep   |    0 |       | NULL             |
+--------+------+-----------------+------+---------+------+-------+------------------+
7 rows in set (0.00 sec)


  • 1
    点赞
  • 5
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值