Bug #16392 mysqld_safe --help command deletes the socket file
Submitted: 12 Jan 2006 0:20 Modified: 31 Mar 2006 21:46
Reporter: Michelle Chen Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:4.1.18-BK, 4.1.14 OS:Linux (Linux, Solaris)
Assigned to: Kent Boortz CPU Architecture:Any

[12 Jan 2006 0:20] Michelle Chen
Description:
I'm running MySQL 4.1.14 Standard. Before I realized there's no --help option for mysqld_safe script before MySQL 5.0, I typed %mysqld_safe --help; and surprisely found out later it deleted the socket file mysql.sock. All my local client connection to the server failed since then. For example, %mysql -u xx -pxx failed because of  the lack of the socket file.

I looked into the mysqld_safe script and tried to find out why. There is something that I think may be related. In normal case, running mysqld_safe even with an undefined option will generate a message such as 'A mysqld process already exists' if the server is up running. However, if the pid file is NOT located in the default directory which should be $DATADIR, running %mysqld_safe with or without --help option will generate the following message:

Starting mysqld daemon with databases from /usr/local/mysql/data
STOPPING server from pid file /usr/local/mysql/data/nms1.pid
060111 15:34:37  mysqld ended

And consequently, the socket file under /tmp is deleted!

I know our system has configured in my.cnf a non-default location for pid  file, and I've tested it on both RedHat Linux platform and Solaris 9.

Please help to find out the real reason. Thank you very much!

- Michelle Chen

How to repeat:
1. Start the MySQL server.
2. If the pid file is located under the default location, move it to somewhere else.
3. Run %mysqld_safe --help or %mysqld_safe
4. Check mysql.sock under /tmp.
[21 Jan 2006 16:29] Valeriy Kravchuk
Thank you for a bug report. Verified just as described with 4.1.18-BK (ChangeSet@1.2481, 2006-01-20 00:08:26+11:00) on Linux:

[openxs@Fedora 4.1]$ bin/mysqld_safe --pid-file=/tmp/Fedora.pid &
[1] 5426
[openxs@Fedora 4.1]$ Starting mysqld daemon with databases from /home/openxs/dbs/4.1/var

[openxs@Fedora 4.1]$ ls -l /tmp
total 1640
-rwx------    1 openxs   openxs     491422 Jan 11 16:39 16082.txt
-rw-rw----    1 openxs   openxs          5 Jan 21 19:12 Fedora.pid
drwx------    3 openxs   openxs       4096 Jan 21 16:22 gconfd-openxs
srwxrwxr-x    1 openxs   openxs          0 Jan 21 16:22 mapping-openxs
srwxr-xr-x    1 root     root            0 Jul 29 12:49 mapping-root
srwxrwxrwx    1 openxs   openxs          0 Jan 21 19:12 mysql.sock
srwxrwxrwx    1 openxs   openxs          0 Oct 30 15:13 mysqlmanager.sock
drwx------    2 openxs   openxs       4096 Jan 21 17:09 orbit-openxs
drwx------    2 root     root         4096 Jan  1  1970 orbit-root
-rwx------    1 openxs   openxs    1152364 Jan 11 20:53 shared3.sql
-rw-rw----    1 mysql    mysql        3828 Jan 14 13:14 slow.log
drwx------    2 openxs   openxs       4096 Jan 21 16:22 ssh-wbuG4428
[openxs@Fedora 4.1]$ bin/mysqld_safe --help
Starting mysqld daemon with databases from /home/openxs/dbs/4.1/var
STOPPING server from pid file /home/openxs/dbs/4.1/var/Fedora.pid
060121 19:12:56  mysqld ended

[openxs@Fedora 4.1]$ ls -l /tmp
total 1640
-rwx------    1 openxs   openxs     491422 Jan 11 16:39 16082.txt
-rw-rw----    1 openxs   openxs          5 Jan 21 19:12 Fedora.pid
drwx------    3 openxs   openxs       4096 Jan 21 16:22 gconfd-openxs
srwxrwxr-x    1 openxs   openxs          0 Jan 21 16:22 mapping-openxs
srwxr-xr-x    1 root     root            0 Jul 29 12:49 mapping-root
srwxrwxrwx    1 openxs   openxs          0 Oct 30 15:13 mysqlmanager.sock
drwx------    2 openxs   openxs       4096 Jan 21 17:09 orbit-openxs
drwx------    2 root     root         4096 Jan  1  1970 orbit-root
-rwx------    1 openxs   openxs    1152364 Jan 11 20:53 shared3.sql
-rw-rw----    1 mysql    mysql        3828 Jan 14 13:14 slow.log
drwx------    2 openxs   openxs       4096 Jan 21 16:22 ssh-wbuG4428

Note, that mysql.sock disappeared. 

mysqld_safe script of 5.0.x works correctly, by the way, giving appropriate messages.
[23 Jan 2006 23:06] Michelle Chen
Is there a fix for the bug except for the upgrade to the new version? Thanks.
- Michelle
[31 Mar 2006 21:46] Kent Boortz
The --help option was back ported from 5.0.