Bug #2114 line misplaced in mysqld_safe
Submitted: 14 Dec 2003 22:06 Modified: 21 Jan 2004 9:56
Reporter: Rodrigo Marchant Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Installing Severity:S2 (Serious)
Version:4.0.16 OS:Linux (Linux)
Assigned to: Lenz Grimmer CPU Architecture:Any

[14 Dec 2003 22:06] Rodrigo Marchant
Description:
mysqld_safe deletes mysql.sock when starting.  When you have more than one instance of mysqld running on the same machine, when you start the second instance, it deletes always /var/lib/mysql.sock, because the variable
safe_mysql_unix_port
is set before parsing all the command-line arguments.

Look at the diff -p2  I´m attaching with this report. It solved the problem for me, as with the patch, the variable is correctly set when you use the
 --socket  option in the command-line.

How to repeat:
Let one instance of mysqld running on the default /var/lib/mysql, and setup another instance on /var/lib/mysql20 (for instance).

Start the first instance, it will create /var/lib/mysql/mysql.sock

When you start the second instance (with the option
--socket=/var/lib/mysql20/mysql.sock ), mysqld_safe will delete /var/lib/mysql/mysql.sock , thus disallowing any local access (i.e., via the unix socket) to the first instance of mysqld

Suggested fix:
*** mysqld_safe Mon Dec 15 05:38:39 2003
--- /usr/bin/mysqld_safe        Sun Dec  7 07:07:08 2003
*************** else
*** 115,119 ****
  fi

- safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-/var/lib/mysql/mysql.sock}}
  user=mysql
  niceness=0
--- 115,118 ----
*************** args=
*** 150,153 ****
--- 149,153 ----
  parse_arguments `$print_defaults --loose-verbose $defaults mysqld server mysqld_safe safe_mysqld`
  parse_arguments PICK-ARGS-FROM-ARGV "$@"
+ safe_mysql_unix_port=${mysql_unix_port:-${MYSQL_UNIX_PORT:-/var/lib/mysql/mysql.sock}}

  if test ! -x $ledir/$MYSQLD
[15 Dec 2003 7:28] Indrek Siitan
Assigned to Lenz, our head build engineer.
[21 Jan 2004 9:56] Lenz Grimmer
Fixed for 4.0.18 and above:

ChangeSet@1.1681.1.6, 2004-01-15 16:14:30+01:00, lenz@mysql.com
   - fixed early removing of socket file when multiple instances of mysqld are
     started via mysqld_safe (BUG#2114) Thanks to Rodrigo Marchant for the
     suggestion