5.13.1 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

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

Options

mysqlprocgrep accepts the following command-line options:

NOTES

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 will allow 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).

EXAMPLES

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

Kill all queries created by user mats that are younger than 1 minute:

mysqlprocgrep --server=root@localhost \
  --match-user=mats --age=-1m --kill-query

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

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

PERMISSIONS REQUIRED

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