Back to commands

Hosting Operations

Read-only, sensitive output

Show Active MySQL Sessions

MySQL is slow or rejecting clients and you need a quick view of active sessions.

Command

mysql -e "show full processlist;"

Before you run this

System impact: Read-only. Output may expose users, paths, tokens, keys, IPs, process arguments, or log details.

When not to use it: Do not use this as the kill step; inspect carefully before terminating sessions.

Expected output

Rows showing connection ID, user, host, database, command, time, state, and query text.

System impact

Read-only, sensitive output. Nothing changes. MySQL prints current sessions and queries.

Recovery / rollback: no state is changed.

When to use it

Use when MySQL feels saturated, slow, or overloaded.

When not to use it

Do not use this as the kill step; inspect carefully before terminating sessions.

next steps

Related commands

Hosting Operations Sensitive output

Find Long-Running MySQL Queries

One old query explained the whole slowdown.

mysql -e "select id,user,host,db,command,time,state,left(info,80) as info from information_schema.processlist where command <> 'Sleep' order by time desc limit 10;"
Hosting Operations Read-only

Show Active PostgreSQL Connections

The database was not down. It was full.

psql -X -A -F '|' -c "select pid,usename,datname,state,client_addr from pg_stat_activity order by state, pid;"
Hosting Operations Read-only

Check PostgreSQL Lock Waits

The outage was a queue, not a crash.

psql -X -c "select pid, wait_event_type, wait_event, state, left(query, 80) as query from pg_stat_activity where wait_event_type is not null order by pid;"
Hosting Operations Sensitive output

Show MySQL Database Sizes

The storage alert needed a database name.

mysql -e "select table_schema, round(sum(data_length + index_length)/1024/1024, 1) as mb from information_schema.tables group by table_schema order by mb desc;"
Study mapping

Use this as independent command practice: read the notes, predict the output, then compare it with the example before using a real shell.

  • LFCS style performance-task practice

Independent study support only. No affiliation, endorsement, exam dumps, or real exam questions.