Bug #5121 MacOS Startup Item fails to work for stop & restart if hostname changes
Submitted: 20 Aug 2004 8:15 Modified: 23 Aug 2004 20:01
Reporter: James Berry Email Updates:
Status: Closed Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S2 (Serious)
Version:4.1.3 OS:MacOS (MacOS X)
Assigned to: CPU Architecture:Any

[20 Aug 2004 8:15] James Berry
Description:
The Mac OS X Startup Item calls the mysql.server script to handle start, stop, and restart chores. 
The mysql.server script calculates the default pid-file name based on the current hostname of the 
computer.

The Mac OS X hostname may change due to network configuration changes (such as wireless 
connectivity coming and going); when this occurs, the default pid file name changes, which 
means that the pid-file name used at start time will not be found when it is time to stop or restart 
the server.

To fix that, the patch below passes a fixed pid file name into the mysql.server script so that the 
pid file will always be found despite changes to the network configuration.

This patch relies on bug fixes to the mysql.server script, which are detailed in bug #5120.

How to repeat:
At startup time, before my wireless network has come up, my hostname is "James.local". 
Subsequently, once wireless connectivity is established, my hostname changes to something 
else. So the pid file name picked at the time the MySQLCOM Startup Item is called is different 
than when system starter is later called to do a restart or stop operation; these operations thus 
fail.

Suggested fix:
The following patch solves this problem by requesting that a pid-file of a constant name is used 
by the MySQLCOM startup item. Note that this relies on bug fixes to the mysql.server script, 
which are detailed in bug #5120.

diff -u MySQLCOM MySQLCOM.patched
--- MySQLCOM    Thu Aug 19 23:11:13 2004
+++ MySQLCOM.patched    Thu Aug 19 21:58:58 2004
@@ -25,25 +25,26 @@
 # The path to the mysql.server init script. The official MySQL
 # Mac OS X packages are being installed into /usr/local/mysql.
 SCRIPT="/usr/local/mysql/support-files/mysql.server"
+SCRIPTARGS="--pid-file=mysql.pid"
 
 StartService ()
 {
        if [ "${MYSQLCOM:=-NO-}" = "-YES-" ] ; then
                ConsoleMessage "Starting MySQL database server"
-               $SCRIPT start > /dev/null 2>&1
+               $SCRIPT start $SCRIPTARGS > /dev/null 2>&1
        fi
 }
 
 StopService ()
 {
        ConsoleMessage "Stopping MySQL database server"
-       $SCRIPT stop > /dev/null 2>&1
+       $SCRIPT stop $SCRIPTARGS > /dev/null 2>&1
 }
 
 RestartService ()
 {
        ConsoleMessage "Restarting MySQL database server"
-       $SCRIPT restart > /dev/null 2>&1
+       $SCRIPT restart $SCRIPTARGS > /dev/null 2>&1
 }
 
 if test -x $SCRIPT ; then
[20 Aug 2004 16:56] James Berry
Per resolution of bug #5120, a simpler way to fix this problem would be to simply add 
pid-file	= mysql.pid
to the [mysqld] section of the my.cnf file.

This would require no patch to either mysql.server or to the MySQLCOM startup item, though it 
would require the default my.cnf to be changed to fix this case.