Back to lessons

Hosting Operations

Check Whether MySQL Responds

An app cannot connect to MySQL and you need to distinguish a dead server from a credential or query issue.

Command

mysqladmin ping -h 127.0.0.1 -P 3306

What changed

Nothing changes. mysqladmin reports whether the server responds.

Danger

safe

When to use it

Use during deploys, restarts, and first-response database checks.

When not to use it

Do not treat ping success as proof that app credentials or schema permissions are correct.

Undo or recovery

No undo needed because this command is read-only.

Expected output

A short response such as mysqld is alive.

demo script

Disposable terminal steps

  1. mysqladmin ping -h 127.0.0.1 -P 3306
  2. mysqladmin status
  3. ss -ltnp | grep ':3306'

simulated output

What it looks like

disposable vessel
::fixture-ready::
$ mysqladmin ping -h 127.0.0.1 -P 3306
mysqld is alive
::exit-code::0
$ mysqladmin status
Uptime: 86400  Threads: 7  Questions: 23890  Slow queries: 3  Opens: 112  Open tables: 64  Queries per second avg: 0.276
::exit-code::0
$ ss -ltnp | grep ':3306'
LISTEN 0      151    0.0.0.0:3306       0.0.0.0:* users:(("mysqld",pid=733,fd=22))
::exit-code::0

YouTube Short

Ping MySQL before guessing.

An open port is not the same as a working database. Ask MySQL whether it is alive.

LinkedIn hook

The port was open. MySQL still had to answer.

Question: Do you separate MySQL reachability from credential checks during incidents?

experiments

A/B tests to run

Metric: short_save_rate

A: The port was open. MySQL still had to answer.

B: Ping MySQL before changing app config.