Bug #3120 'mysqladmin ping' - return error code
Submitted: 9 Mar 2004 10:59 Modified: 10 Sep 2004 11:01
Reporter: Ruslan Kosolapov Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version:4 OS:Linux (Suse Linux 9.0)
Assigned to: Ramil Kalimullin CPU Architecture:Any

[9 Mar 2004 10:59] Ruslan Kosolapov
Description:
In mysql.user I have only one user 'admin' with password 'setup'.

# mysqladmin ping
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user: 'root@localhost' (Using password: NO)'

But as I understand mysqladmin ping must return 0 if mysql is running.  Now it's returning 1.

I think this is not right - 'permission denied' and 'connection refused' is the different things, and at this case mysqladmin ping must return 0.

In Suse /etc/init.d/mysql (i.e. init-script for mysql) use 'mysqladmin ping', and in my situation happens next:
-----8<---------------------------------------------
# sh -x /etc/init.d/mysql start
+ test '!' -d /var/lib/mysql/mysql
+ echo 'Starting service MySQL'
Starting service MySQL
+ /usr/bin/mysqld_safe --user=mysql --pid-file=/var/lib/mysql/mysqld.pid
--socket=/var/lib/mysql/mysql.sock --datadir=/var/lib/mysql
+ sleep 1
+ /usr/bin/mysqladmin ping
+ sleep 1
+ /usr/bin/mysqladmin ping
+ sleep 1
+ /usr/bin/mysqladmin ping
+ sleep 1
+ /usr/bin/mysqladmin ping
+ sleep 1
+ /usr/bin/mysqladmin ping
+ sleep 1
+ /usr/bin/mysqladmin ping
+ test -z 6
+ rc_failed
........
+ echo -e ''                                                  failed
                                                              failed
+ _rc_status=0
+ return 1
+ rc_exit
+ exit 1

# mysqladmin ping
mysqladmin: connect to server at 'localhost' failed
error: 'Access denied for user: 'root@localhost' (Using password: NO)'

# mysqladmin -uadmin -psetup ping
mysqld is alive
----------------------------------------------->8---

How to repeat:
Just delete user 'root' from mysql.user, and type

# mysqladmin ping

Suggested fix:
I propose return 1 only if mysqld is not running (i.e. answer from mysqld is 'connection refused').
[10 Sep 2004 11:01] Ramil Kalimullin
Thank you for your bug report. This issue has been committed to our
source repository of that product and will be incorporated into the
next release.

If necessary, you can access the source repository and build the latest
available version, including the bugfix, yourself. More information 
about accessing the source trees is available at
    http://www.mysql.com/doc/en/Installing_source_tree.html