MySQL CLI Cheatsheet
Top commands.
Overview
The MySQL CLI cheatsheet captures the patterns operators actually use during MySQL investigation. SHOW PROCESSLIST and EXPLAIN are the core; Performance Schema is what scales investigation past one engineer’s head.
- Top commands.
SHOW PROCESSLIST,EXPLAIN,SHOW INDEX,SHOW STATUS; the four investigation paths. - SHOW PROCESSLIST. Active queries snapshot; first call when investigating "what is the database doing right now?"
- EXPLAIN ANALYZE. Real execution stats with row counts and timing; the diagnostic for slow queries.
- Performance Schema plus slow query log. Top queries by load over time; per-query slow log for the chronic offenders.
The approach
The practical approach: SHOW PROCESSLIST first for live issues, EXPLAIN everything slow, Performance Schema for sustained load patterns. The team’s discipline produces fast investigation.
- SHOW PROCESSLIST. Active queries; the live snapshot during incidents; spot the long-running query immediately.
- EXPLAIN ANALYZE SELECT ... Real execution with row counts and timing; reveals plan choice and index usage.
- SHOW INDEX FROM table. Index inspection; the foundation of query tuning; missing index is the most common slow-query cause.
- performance_schema.events_statements_summary_by_digest. Top queries by load; the chronic-offender list; tuning targets prioritised.
- Document the queries. Per-table access patterns committed to the repo; supports operational reviews and onboarding.
Why this compounds
MySQL CLI fluency compounds across investigations. Each query teaches a MySQL pattern; the team’s database expertise accrues; cost-per-incident falls as the muscle matures.
- Faster MySQL debugging. Fluent CLI produces fast root cause; the slow query is identified before the user complains.
- Better query performance.
EXPLAINreveals slow queries before production scale; tune at PR time, not incident time. - Better investigation. Performance Schema reveals hot queries; the per-digest aggregation is the load pattern view.
- Institutional knowledge. Each query teaches MySQL internals; the team’s database engineering muscle grows.
MySQL CLI fluency is an operational discipline that pays off across years. Nova AI Ops integrates with database telemetry, surfaces patterns, and supports the team’s database engineering discipline.