Skip to content
Latchkey

mysqladmin: Usage, Options & Common CI Errors

mysqladmin runs administrative commands like ping, status, and create on MySQL.

mysqladmin ping is the canonical "wait for MySQL" probe in CI. The whole pattern depends on knowing that ping reports success even when access is denied, which is usually what you want for readiness.

What it does

mysqladmin performs administrative operations on a MySQL/MariaDB server: checking liveness (ping), showing status and variables, creating/dropping databases, and flushing. In pipelines its main job is the readiness probe before migrations run.

Common usage

Terminal
mysqladmin -h 127.0.0.1 -u root -psecret ping
until mysqladmin -h 127.0.0.1 -u root -psecret ping --silent; do sleep 1; done
mysqladmin -h 127.0.0.1 -u root -psecret status
mysqladmin -h db -u root -psecret create app_test

Options

Command / flagWhat it does
pingCheck whether the server is alive
statusShow uptime, threads, queries
create / drop <db>Create / drop a database
--wait[=N]Retry the connection N times
--silentSuppress output (rely on exit code)
flush-hosts / flush-logsFlush host cache / logs

Common errors in CI

mysqladmin: connect to server at '127.0.0.1' failed: Can't connect ... (111) means the server is still starting - loop on ping until it succeeds. Note ping prints "mysqld is alive" and exits 0 even on "Access denied" because the server answered, which is fine for a readiness gate but means ping does not validate credentials. Use -h 127.0.0.1 (not localhost) to force TCP to the service container rather than a missing local socket.

Related guides

Run this faster and cheaper on Latchkey managed runners. Start free →