Sometimes you only want to know whether the database server is alive, without opening a SQL session. mysqladmin does that in one line.
mysqladmin -u root -p ping
mysqladmin -u root -p status
According to the MySQL manual, ping checks whether the server is available, and status displays a short status message. The status line has the uptime in seconds, the number of threads, questions, slow queries, opens, flush tables, open tables and the average queries per second.
ping is the one for scripts, because of its exit code. It returns 0 if the server is running and 1 if it is not:
mysqladmin ping --silent && echo up || echo down
The manual points out that the exit code is 0 even when the answer is an error like Access denied, because a refused connection still means the server is running. A health check in a Docker container or a cron job can use this.
The status output is easy to read and nothing else. For a closer look at what is running, use mysqladmin processlist or the SQL shell.
The caveat is that a good ping says the server answers, not that the application can use the database. A wrong password gives exit code 0 as well, so credentials are not tested by it. For a real check, run a small query with the account your app uses.
Further reading: MySQL manual: mysqladmin