如何查看MySQL连接有多少是开放的? [英] How can I see how many MySQL connections are open?

查看:134
本文介绍了如何查看MySQL连接有多少是开放的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎么能看到多少个连接在当前请求期间通过 mysql_connect 在PHP中打开在Apache上运行?

How can I see how many connections have been opened during the current request via mysql_connect in PHP running on Apache?

我知道,如果我叫 mysql_connect 函数100次使用相同的参数,它总是返回相同的连接链路。一旦连接已经存在,它不会启动新的连接。

I know that if I call mysql_connect function 100 times with the same parameters, it will always return the same connection link. It will not start new connection once the connection already exists.

但我只是想确认 mysql_connect 不是开始一个新的。

But I just want to make sure mysql_connect is not starting a new one.

我与其中包含许多 mysql_connect 函数调用遗留系统的工作。

I am working with a legacy system which contains many mysql_connect function calls.

是否有任何的Apache设置或有什么办法我可以登录这个数字在Apache或MySQL的日志文件的连接?

Is there any setting in Apache or is there any way I can log this number of connections in Apache or MySQL log file?

推荐答案

我认为有几个方面:

SHOW STATUS WHERE `variable_name` = 'Threads_connected'

或者你可以做一个 SHOW PROCESSLIST 并找出在编号列的唯一值。在旧的PHP API 的mysql ,有<一个href=\"http://php.net/manual/en/function.mysql-list-processes.php\"><$c$c>mysql_list_processes函数,它同 SHOW PROCESSLIST 了。

or you can do a SHOW PROCESSLIST and find out unique values in the Id column. In old PHP API mysql, there is mysql_list_processes function that does the same as SHOW PROCESSLIST, too.

但第一个应该为你工作。也许你可能想检查其他状态变量

But first one should work for you. And perhaps you might like to check on other STATUS variables

这篇关于如何查看MySQL连接有多少是开放的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆