Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MySQL - how to SHOW PROCESSLIST only with current user's processes?

Tags:

mysql

Is there a way in MySQL 5 to show only the current user's processes(queries)?

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.

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.

like image 421
Piskvor left the building Avatar asked Dec 02 '08 15:12

Piskvor left the building


1 Answers

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.

This feature is not implemented in MySQL 5.0 and prior.

like image 99
Bill Karwin Avatar answered Sep 30 '22 01:09

Bill Karwin