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
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_testOptions
| Command / flag | What it does |
|---|---|
| ping | Check whether the server is alive |
| status | Show uptime, threads, queries |
| create / drop <db> | Create / drop a database |
| --wait[=N] | Retry the connection N times |
| --silent | Suppress output (rely on exit code) |
| flush-hosts / flush-logs | Flush 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.