Take the 2-minute tour ×
Server Fault is a question and answer site for professional system and network administrators. It's 100% free, no registration required.

I'm trying to monitor whether our mysql server is up. The command I'm using for this is:

mysqladmin ping

It will return the following:

mysqld is alive

Does this just check whether the process is currently running or does it also check whether the server is accepting connections?

share|improve this question

2 Answers 2

up vote 3 down vote accepted

"mysqladmin ping" attempts to connect to the chosen MySQL server. The actual server can be specified with the -h option (e.g. mysqladmin ping -h db.example.com), defaulting to localhost.

If the server responds (even with an access denied or similar message), the server is assumed to be alive and "mysqladmin ping" exits with code 0.

Otherwise, the server is assumed to be down and "mysqladmin ping" exists with code 1.

share|improve this answer

If you want to be certain that your MySQL server is up, the best thing to do is to write a small script to execute:

SELECT "1";

Your user for connecting would need at least USAGE permission. This won't tell you if there are any problems with your database tables, but your application monitoring will probably tell you this.

It's entirely possible that this is what mysqladmin ping does anyway.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.