Bug #25102 mysqld_safe ignores --datadir
Submitted: 15 Dec 2006 18:28 Modified: 22 Dec 2006 11:37
Reporter: Mikael Ronström Email Updates:
Status: Can't repeat Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.0.27 OS:
Assigned to: CPU Architecture:Any

[15 Dec 2006 18:28] Mikael Ronström
Description:
mysqld_safe doesn't care about --datadir

How to repeat:
mysqld_safe --datadir /usr/local/mysql/var
Using binary distribution installed through rpm's
Will use /var/lib/mysql

Suggested fix:
if DATADIR has been set by option then don't overwrite it later on without checking
if it has already been set.
[15 Dec 2006 18:31] Mikael Ronström
Looking at the mysqld_safe script the issue seems to be the same also using the options
--basedir and --ledir
[15 Dec 2006 18:44] Mikael Ronström
Looking at the mysqld_safe script the issue seems to be the same also using the options
--basedir and --ledir
[15 Dec 2006 18:45] Mikael Ronström
simply missed the fact that --datadir /usr/local/mysql/var was wrong
should have been
--datadir=/usr/local/mysql/var
[15 Dec 2006 18:51] Mikael Ronström
The = was needed but the bug was actually reproducable again
[22 Dec 2006 8:43] Sveta Smirnova
Thank you for the report.

I can not repeat it using current BK sources:

ssmirnova@shella ~/mysql5.0b
$ls vard
ls: vard: No such file or directory

ssmirnova@shella ~/mysql5.0b
$bin/mysqld_safe --defaults-file=support-files/my-small.cnf --datadir=./vard &
[1] 7207

ssmirnova@shella ~/mysql5.0b
$Starting mysqld daemon with databases from ./vard
bin/mysqld_safe: line 379: ./vard/shella.mysql.com.err: No such file or directory
bin/mysqld_safe: line 387: ./vard/shella.mysql.com.err: No such file or directory
STOPPING server from pid file ./vard/shella.mysql.com.pid
tee: ./vard/shella.mysql.com.err: No such file or directory
061222 09:42:45  mysqld ended
tee: ./vard/shella.mysql.com.err: No such file or directory

[1]+  Exit 1                  bin/mysqld_safe --defaults-file=support-files/my-small.cnf --datadir=./vard

ssmirnova@shella ~/mysql5.0b
$
[18 Aug 2010 22:05] Mikhail T
I'm seeing the same thing with 5.1.44. The bug is in the mysqld_safe script -- the DATADIR and the ledir variables are set before the command-line arguments are passed.

I'll attached the patch, that seems to be working for us... It pushes the line
parse_arguments PICK-ARGS-FROM-ARGV "$@"
to the very top (write after the function is defined), and makes the search for DATADIR happen only, if it is not already specified.
[18 Aug 2010 22:06] Mikhail T
Patch the mysqld_safe script to honor the basedir and the datadir command-line arguments

Attachment: mysqld_safe.patch (text/x-patch), 1.43 KiB.