MySQL-如何仅在当前用户的进程中显示PROCESSLIST? [英] MySQL - how to SHOW PROCESSLIST only with current user's processes?
问题描述
MySQL 5中是否有办法仅显示当前用户的进程(查询)?
Is there a way in MySQL 5 to show only the current user's processes(queries)?
用户具有PROCESS
特权,因此SHOW PROCESSLIST
显示所有用户的运行进程.根据文档,SHOW PROCESSLIST
不允许任何类型的WHERE
语法,我也没有设法使其成为子查询.
The user has the PROCESS
privilege, therefore SHOW PROCESSLIST
displays running processes of all users. According to the documentation, SHOW PROCESSLIST
does not allow any kind of WHERE
syntax, nor did I manage to make it into a subquery.
当然,我可以简单地发送查询,例如在PHP脚本中,然后循环遍历结果,丢弃所有非我的东西,但效率似乎很低.更改用户权限是不可行的.
Of course, I could simply send the query, e.g. in a PHP script, and go through the results in a loop, discarding everything that's not mine, but it seems rather inefficient. Changing the user privileges is not feasible.
还有其他方法吗?预先感谢.
Are there any other ways? Thanks in advance.
推荐答案
If you use MySQL 5.1.7 or newer, you can use the PROCESSLIST table in the INFORMATION_SCHEMA. So you can query it with ordinary SELECT
queries and apply filtering conditions in a WHERE
clause.
此功能在MySQL 5.0及更高版本中未实现.
This feature is not implemented in MySQL 5.0 and prior.
这篇关于MySQL-如何仅在当前用户的进程中显示PROCESSLIST?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!