Bug #44624 --defaults-file only works correctly as first option
Submitted: 3 May 2009 5:46 Modified: 3 Jun 2009 7:55
Reporter: gerhard mittermayer Email Updates:
Status: No Feedback Impact on me:
None 
Category:MySQL Server Severity:S2 (Serious)
Version:5.1/5.4 OS:Linux (Debian )
Assigned to: CPU Architecture:Any
Tags: --defaults-file, unknown option

[3 May 2009 5:46] gerhard mittermayer
Description:
Hello,

At commandline start (mysqld_safe and mysqld. the option --option-file= works only if it the first option in line.

Worse, you can get into real troubles if you have already another "first" instance using /etc/mysql/my.cnf and try to start second one by command line.

Lets say you start it with mysqld_safe --user=mysql2 --defaults-file/etc/mysql2/my.cnf

Server will cause following errors:
Cannot change user because user mysql (user from any my.cnf in standard paths) was.. earlier in the script

also maybe some unknoe options errors aper if another my.cnf has an not compiled in option specified.

But when you think it cant be worse.. 
The best thing about this is that the given options file will be read in and will be used for some parts.

And that what he is doing:
if default-file isnt first option he will try to find in /etc/my.cnf, /etc/mysql/my.cnf,.... another options file after that he use the specified one

if you use only one instance or if you have no regular named cnf in the search paths you wont recognize it.

after the new instance crash (cause of some illeagal options) it will kill your first instance too in most cases

even worse if you use the same user for the first and second instance you run into seriouse trouble.

and the worst part is you can compile with another user and fixed another options file - it wont help, then hell take another cnf file anyway

togehter with this problems seems to be the mysql.server script similar problem and kills all instances with mysql 5.x at stop while instance mysql4.1 still alive

How to repeat:
copy one wrong my.cnf into /etc/mysql/my.cnf or install a regular first instance

use binary or compiled second one and start the mysqld_safe --user=seconduser --defaults-file=/etc/mysql2/my.cnf ....

Suggested fix:
Together with the fix i recomend a big warning in the documentation for multiple instances (doenst matter if its the same version or different) that you should use different user for different instances on one host.

it saves me a lot trouble and protect me from a worst case (like second host try to write into instance one datadir). its always a good idea to do this and more secure
[3 May 2009 7:55] Valeriy Kravchuk
Thank you for the problem report. What exactly do you want to be changed or documented? I think current behavior is clearly described in the manual. Check http://dev.mysql.com/doc/refman/5.1/en/option-files.html, please:

...

"Most MySQL programs that support option files handle the following options. They affect option-file handling, so they must be given on the command line and not in an option file. To work properly, each of these options must immediately follow the command name, with the exception that --print-defaults may be used immediately after --defaults-file or --defaults-extra-file."

...
[3 Jun 2009 23:00] Bugs System
No feedback was provided for this bug for over a month, so it is
being suspended automatically. If you are able to provide the
information that was originally requested, please do so and change
the status of the bug back to "Open".
[29 Sep 2010 10:33] Roel Van de Paar
See bug #57093