Bug #52720 sometimes mysqld_safe does not use the good mysqld path
Submitted: 9 Apr 2010 13:38 Modified: 12 Apr 2010 8:29
Reporter: Cyril SCETBON Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.1.45 OS:Any
Assigned to: CPU Architecture:Any
Tags: MySQL, mysqld_safe, script

[9 Apr 2010 13:38] Cyril SCETBON
Description:
FYI, We are in a case where we're using more than one version on a single host.

Even if we provide the path of mysqld to mysqld_safe, if --ledir option  is not defined, mysqld_safe uses the default path concatenated to the path provided.

How to repeat:
/usr/local/mysql/5.1.45/bin/mysqld_safe --defaults-file=/WOO/DATA/sandboxes/msb_5_1_45/my.sandbox.cnf --mysqld=/usr/local/mysql/5.1.45/bin/mysqld

--> 

The file /usr/local/mysql/bin//usr/local/mysql/5.1.45/bin/mysqld
does not exist or is not executable. Please cd to the mysql installation
directory and restart this script from there as follows:
./bin/mysqld_safe&

But if we set --ledir option to an empty string

/usr/local/mysql/5.1.45/bin/mysqld_safe --defaults-file=/WOO/DATA/sandboxes/msb_5_1_45/my.sandbox.cnf --mysqld=/usr/local/mysql/5.1.45/bin/mysqld --ledir=

--> everything is fine :)

the first error comes from the fact that mysqld_safe checks the mysqld path provided but does not use it as it's provided.

+ test -z /usr/local/mysql/5.1.45/bin/mysqld
+ test '!' -x /usr/local/mysql/bin//usr/local/mysql/5.1.45/bin/mysqld

Suggested fix:
use the path provided without modifying it
[9 Apr 2010 13:42] Cyril SCETBON
I should say it concatenates the default bindir path (guessed from the basedir default path, even if I've set the basedir option in the defaults-file provided) to the mysqld path provided to be more precise.
[9 Apr 2010 16:14] Sveta Smirnova
Thank you for the report.

According to http://dev.mysql.com/doc/refman/5.1/en/mysqld-safe.html#option_mysqld_safe_mysqld:

----<q>----
--mysqld=prog_name

The name of the server program (in the ledir directory) that you want to start. This option is needed if you use the MySQL binary distribution but have the data directory outside of the binary distribution. If mysqld_safe cannot find the server, use the --ledir option to indicate the path name to the directory where the server is located. 
----</q>----

So mysqld_safe's behavior is correct and this is not a bug.
[12 Apr 2010 8:29] Cyril SCETBON
ok, so ledir option is mandatory if mysqld is not in the default path, and it's not really useful to provide an absolute path in mysqld optoin. Maybe mysqld_safe should disallow absolute path in mysqld option as in this case ledir option must be defined to and empty string.