↑ ↓ select, Enter open, Esc close

Show running MySQL queries without idle connections

root@server
mysql -e "SELECT id, user, db, time, state, LEFT(info, 100) AS query FROM information_schema.processlist WHERE command <> 'Sleep' ORDER BY time DESC;"

Reads the process list and hides sleeping connections. It shows ID, user, database, runtime in seconds, state and the first 100 characters of the query. The first thing to check under high database load or when pages hang.

Note: SHOW FULL PROCESSLIST; shows the complete list including idle connections. On Plesk servers, run it as admin.

Also searched as

  • mysql high load
  • which query is hanging
  • show mysql process list

Related one-liners

All in MySQL and MariaDB

Read first, then run.

The commands on myline.de act directly on servers, files and databases. A wrong path or placeholder can delete data irreversibly or make a server unreachable.

  • All commands are provided without warranty and are not tested on every system.
  • Understand what a command does before running it, and check every placeholder.
  • Make a backup first and, if possible, try it on a test system.
  • You run commands at your own risk. Liability for damages is excluded to the extent permitted by law.