MySQL Utilities

5.17 mysqlprocgrep — Search Server Process Lists

This utility scans the process lists for the servers specified using instances of the --server option and selects those that match the conditions specified using the --age and --match-xxx options. For a process to match, all conditions given must match. The utility then either prints the selected processes (the default) or executes certain actions on them.

If no --age or --match-xxx options are given, the utility selects all processes.

The --match-xxx options correspond to the columns in the INFORMATION_SCHEMA.PROCESSLIST table. For example, --match-command specifies a matching condition for PROCESSLIST.COMMAND column values. There is no --match-time option. To specify a condition based on process time, use --age.

Processes that can be seen and killed are subject to whether the account used to connect to the server has the PROCESS and SUPER privileges. Without PROCESS, the account cannot see processes belonging to other accounts Without SUPER, the account cannot kill processes belonging to other accounts.

When the --kill-query or --kill-connection option is used, the utility displays those rows from the SHOW PROCESSLIST that match the query and are killed. This behavior exists as of MySQL Utilities 1.6.0.

To specify how to display output, use one of the following values with the --format option:


mysqlprocgrep accepts the following command-line options:


For the --format option, the permitted values are not case-sensitive. In addition, values may be specified as any unambiguous prefix of a valid value. For example, --format=g specifies the grid format. An error occurs if a prefix matches more than one valid value.

The path to the MySQL client tools should be included in the PATH environment variable in order to use the authentication mechanism with login-paths. This permits the utility to use the my_print_defaults tools which is required to read the login-path values from the login configuration file (.mylogin.cnf).


For each example, assume that the root user on localhost has sufficient privileges to kill queries and connections.

Kill all connections created by user john:

shell> mysqlprocgrep --server=root@localhost \
          --match-user=john --kill-connection --format=CSV
# The following KILL commands were executed:

Kill all connections that have been idle for more than 1 hour:

shell> mysqlprocgrep --server=root@localhost \
          --match-command=sleep --age=1h --kill-connection


The user must have the SELECT privilege on the mysql database.