MySQL / MariaDB operations
v0.1.11Read-only MySQL diagnostics plus narrow operator actions for killing queries, flushing logs, and analyzing tables. Authenticates via ~/.my.cnf or MYSQL_PWD env var on the runner host — never via per-call credentials over the wire.
mysql
Install
emisar pack install
fetches this pack, re-validates it, and verifies its content hash against the
--hash
below — the exact bytes this page was rendered against, so a tampered copy is
rejected — before copying it into the runner's packs dir. The command reloads a
running daemon itself; no manual restart.
sudo emisar pack install mysql --hash sha256:3f2741d64d6887b922715a42852b69884d0fcb937ffda316db0727fa14ba59d8
Setup
The mysql client reads its password and connection target from its own environment variables on the runner host; the actions pass no connection flags. The username is not taken from the environment — it comes from
~/.my.cnf
or defaults to the runner's OS user.
Environment
Set these on the runner host, then add each name to
execution.inherit_env
so the value reaches the action.
-
MYSQL_PWDPassword for the connecting user. Prefer
~/.my.cnfinstead — env-var passwords are visible in the process list. -
MYSQL_HOSTdefault localhostServer host for TCP connections.
-
MYSQL_TCP_PORTdefault 3306Server TCP port.
-
MYSQL_UNIX_PORTUnix socket path, used when connecting to localhost.
Notes
-
Cleanest credential store:
~/.my.cnf(mode 0600) on the runner host with [client] user/password/host — read from disk, so it needs noinherit_enventry. -
The username is never read from the environment; set it in
~/.my.cnf, otherwise it defaults to the runner's OS user. - Mutators (kill_query, kill_connection, flush_logs, analyze_table, optimize_table) need a user with PROCESS/RELOAD and the relevant table privileges.
Verify it works
Runs mysql.uptime, a low-risk
read that confirms the pack can reach its target. Run it on the host once the pack
is installed; pack install runs it for
you.
sudo emisar pack verify mysql
Install and configure a pack walks through the whole sequence on a host.
Actions 25 total
View on GitHub-
mysql.analyze_table exec medium Medium — changes state, easily reversible
ANALYZE TABLE
Refresh the optimizer statistics for one table. Per-table only; cannot wildcard.
View source on GitHub -
mysql.binlog_positions exec low Low — read-only or trivially reversible
Binary log files
`SHOW BINARY LOGS` — every binlog file with its size. Use to plan binlog disk pressure.
View source on GitHub -
mysql.connections_summary exec low Low — read-only or trivially reversible
Connection counts + cap
Show connected vs max_connections + breakdown by host. Use to check "are we close to connection exhaustion?"
View source on GitHub -
mysql.db_sizes exec low Low — read-only or trivially reversible
Database sizes
Show per-database data + index size summary. Read-only.
View source on GitHub -
mysql.engines exec low Low — read-only or trivially reversible
SHOW ENGINES
List available storage engines and which is default. Read-only.
View source on GitHub -
mysql.flush_logs exec medium Medium — changes state, easily reversible
FLUSH LOGS
Close and reopen all log files (general, slow, error, binary). Use after rotating with logrotate.
View source on GitHub -
mysql.flush_status exec medium Medium — changes state, easily reversible
FLUSH STATUS
Reset the GLOBAL STATUS counters to zero. Use before a workload to get a clean rate measurement window.
View source on GitHub -
mysql.gtid_executed exec low Low — read-only or trivially reversible
GTID executed set
`SELECT @@GLOBAL.gtid_executed` — every GTID this server has applied. Use to compare primary vs replica progress.
View source on GitHub -
mysql.index_unused exec low Low — read-only or trivially reversible
Unused indexes
List indexes with zero reads since uptime — candidates for dropping (frees disk + speeds writes). Read-only.
View source on GitHub -
mysql.innodb_status exec medium Medium — changes state, easily reversible
SHOW ENGINE INNODB STATUS
Show full InnoDB engine status — buffer pool, latest deadlock detected, longest waiting transaction, undo space, log sequence number. The canonical "InnoDB is sick" diagnostic. Rated medium because the status blob embeds live SQL from the latest deadlock and active transactions, which can include literal request values no redaction list can enumerate.
View source on GitHub -
mysql.kill_connection exec high High — service-affecting
KILL (terminate connection)
Terminate one connection. Use to clean up a stuck/idle session. Client sees "lost connection" and must reconnect.
View source on GitHub -
mysql.kill_query exec high High — service-affecting
KILL QUERY (cancel statement)
Cancel the currently-executing query on one connection. Connection survives — pair with `kill_connection` to terminate the session entirely.
View source on GitHub -
mysql.lock_waits exec low Low — read-only or trivially reversible
Lock-wait graph
Join performance_schema.data_lock_waits with data_locks to show who is blocking whom. Use before a kill_query — you want the blocker, not the victim.
View source on GitHub -
mysql.master_status exec low Low — read-only or trivially reversible
SHOW MASTER STATUS
Show current binary log file, position, and GTID set on the primary. Read-only.
View source on GitHub -
mysql.open_tables exec low Low — read-only or trivially reversible
SHOW OPEN TABLES
List tables currently in the table cache. Read-only.
View source on GitHub -
mysql.optimize_table exec high High — service-affecting
OPTIMIZE TABLE
Rebuild the table to reclaim space and re-sort the clustered index. **Holds an exclusive lock for the duration** on non-InnoDB engines; InnoDB tables get an online ALTER. Per-table only.
View source on GitHub -
mysql.processlist exec medium Medium — changes state, easily reversible
SHOW FULL PROCESSLIST
List every active connection with its current command, state, and full query. The first stop for "what is the DB doing?" Rated medium because the output carries live query text, which can include literal request values no redaction list can enumerate.
View source on GitHub -
mysql.replica_status exec low Low — read-only or trivially reversible
SHOW REPLICA STATUS
Read SHOW REPLICA STATUS (or SHOW SLAVE STATUS on old versions). Surfaces lag, last error, IO and SQL thread state, and binlog position. Returns 'not a replica' cleanly when this is a primary.
View source on GitHub -
mysql.slow_queries exec low Low — read-only or trivially reversible
Top slow query digests
Read performance_schema.events_statements_summary_by_digest — top N statement fingerprints by mean execution time. Requires performance_schema enabled. Stays low — DIGEST_TEXT is a normalized fingerprint (literal values replaced with `?`), so the output is the query shape and table/column names, not real request data.
View source on GitHub -
mysql.status exec low Low — read-only or trivially reversible
SHOW GLOBAL STATUS (filtered)
Show global counters filtered by glob pattern. Default returns connection + thread counters.
View source on GitHub -
mysql.table_io_summary exec low Low — read-only or trivially reversible
Top tables by IO wait
List top 30 tables ordered by total I/O wait time. Identifies tables driving disk pressure.
View source on GitHub -
mysql.table_sizes exec low Low — read-only or trivially reversible
Top tables by total size
List top N tables ordered by (data + index) size in bytes. Read-only.
View source on GitHub -
mysql.uptime exec low Low — read-only or trivially reversible
Uptime + version
Return SELECT VERSION() and uptime from SHOW STATUS. Read-only.
View source on GitHub -
mysql.users_grants exec low Low — read-only or trivially reversible
List users + grants summary
List user + host pairs from mysql.user. Doesn't dump grants (volume) — use for audit "who has accounts?"
View source on GitHub -
mysql.variables exec low Low — read-only or trivially reversible
SHOW GLOBAL VARIABLES (filtered)
Show global variables filtered by glob pattern. Default returns InnoDB + buffer settings.
View source on GitHub