| Bug #5120 | mysql.server script doesn't heed --pid-file argument; other bugs | ||
|---|---|---|---|
| Submitted: | 20 Aug 2004 8:00 | Modified: | 20 Aug 2004 12:40 |
| Reporter: | James Berry | Email Updates: | |
| Status: | Not a Bug | Impact on me: | |
| Category: | MySQL Server: Command-line Clients | Severity: | S3 (Non-critical) |
| Version: | 4.1.3 | OS: | MacOS (MacOS) |
| Assigned to: | CPU Architecture: | Any | |
[20 Aug 2004 8:16]
James Berry
Accompaning bug requesting fix to Mac OS X startup item is #5121.
[20 Aug 2004 12:40]
Sergei Golubchik
Thank you for taking the time to write to us, but this is not a bug. Please double-check the documentation available at http://www.mysql.com/documentation/ and the instructions on how to report a bug at http://bugs.mysql.com/how-to-report.php Additional info: mysql.start is not expected to accept command-line arguments besides start/stop. In fact it is written in the script itself: # If you install MySQL on some other places than @prefix@, then you # have to do one of the following things for this script to work: ... # If you want to affect other MySQL variables, you should make your changes # in the /etc/my.cnf, ~/.my.cnf or other MySQL configuration files.
[20 Aug 2004 16:53]
James Berry
Ah, yes. I must have been asleep last night. The correct way to fix this problem is to add pid-file = mysql.pid to the [mysqld] section of the my.cnf file. Thank-you.

Description: The mysql.server script has at least two bugs: (1) It doesn't parse its arguments in order to set the pid_file variable to support non-default pid files, even though this variable is supported in the script. (2) In trying to support restart functionality, arguments are not passed back to the recursive invocation of the script. This bug fix is needed in conjunction with another patch I'll submit in a moment, which fixes a problem on Mac OS where the hostname can change due to network connectivity changes; in such a case, the use of the default pid file name will cause a problem as the name will change. In such a case the mysql pid file will not be found to support restart or stop functionality. The patch for the Mac OS startup item ends up calling mysql.server script with fixed-name pid file. How to repeat: (1) Note that calling mysql.server start --pid-file=foobar.pid does not cause the server to use the foobar.pid pid file. (2) Note that if (1) were fixed, and a non-default pid were used, the pid-file argument is not passed to the recursive invocation of the function used to support restart; restart is broken for this case. Suggested fix: Patch does two things: (1) Pass arguments to the script into the parse_arguments function (2) Move start and stop functionality into functions. Call these functions for start, stop, and restart. This change results in restart knowing the name of the pid file. diff -u mysql.server mysql.server.patched --- mysql.server Thu Aug 19 22:43:04 2004 +++ mysql.server.patched Thu Aug 19 22:41:48 2004 @@ -126,6 +126,7 @@ fi parse_arguments `$print_defaults $extra_args mysqld server mysql_server mysql.server` +parse_arguments "$@" # # Set pid file if not given @@ -140,11 +141,7 @@ esac fi -# Safeguard (relative paths, core dumps..) -cd $basedir - -case "$mode" in - 'start') +do_start() { # Start daemon if test -x $bindir/mysqld_safe @@ -160,9 +157,9 @@ else echo "Can't execute $bindir/mysqld_safe from dir $basedir" fi - ;; +} - 'stop') +do_stop() { # Stop daemon. We use a signal here to avoid having to know the # root password. if test -s "$pid_file" @@ -192,14 +189,26 @@ else echo "No mysqld pid file found. Looked for $pid_file." fi +} + +# Safeguard (relative paths, core dumps..) +cd $basedir + +case "$mode" in + 'start') + do_start + ;; + + 'stop') + do_stop ;; 'restart') # Stop the service and regardless of whether it was # running or not, start it again. - $0 stop - $0 start - ;; + do_stop + do_start + ;; *) # usage