Bug #79280 mysqld --initialize --defaults-file is ignored if appended
Submitted: 13 Nov 2015 21:07 Modified: 14 Nov 2015 0:56
Reporter: Mario Beck Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server: Installing Severity:S3 (Non-critical)
Version:5.7.9 OS:Oracle Linux (OL7)
Assigned to: CPU Architecture:Any
Tags: defaults-file, initialize, mysqld

[13 Nov 2015 21:07] Mario Beck
Description:
"mysqld --initialize --defaults-file" ignores the option "--defaults-file". There is no error. It is just ignored and /etc/my.cnf is read instead.
This is confusing.

"mysqld --defaults-file=... --initialize" works as expected.

How to repeat:
I installed from the tar distribution.

[Sandbox 5]$ pwd
/home/testy/fabric-5.7/5
[Sandbox 5]$ mysqld --version
mysqld  Ver 5.7.9-enterprise-commercial-advanced for linux-glibc2.5 on x86_64 (MySQL Enterprise Server - Advanced Edition (Commercial))
[Sandbox 5]$ cat /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
[Sandbox 5]$ cat ./my.cnf 
[mysqld]
datadir=/home/testy/fabric-5.7/5/data
[Sandbox 5]$ mysqld --initialize --defaults-file=./my.cnf
mysqld: Can't create directory '/var/lib/mysql/' (Errcode: 17 - File exists)
...
2015-11-13T21:00:09.028747Z 0 [ERROR] Aborting

mysqld --defaults-file=./my.cnf --initialize 
works as expected.

Suggested fix:
I expect that options from --defaults-file are read and used, independent of the order of options to mysqld.

If this is not possible, I expect to get an error when the specified option "--defaults-file" is ignored.
[14 Nov 2015 0:56] MySQL Verification Team
Thank you for the bug report. Output of:

C:\dbs>5.7\bin\mysqld --help --verbose

<CUT>
The following options may be given as the first argument:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file,
                        except for login file.
--defaults-file=#       Only read default options from the given file #.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

<CUT>

mysqld  Ver 5.7.9-log for Linux on x86_64 (MySQL Community Server (GPL))
Copyright (c) 2000, 2015, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.

Starts the MySQL database server.

Usage: mysqld [OPTIONS]

Default options are read from the following files in the given order:
/etc/my.cnf /etc/mysql/my.cnf /usr/etc/my.cnf ~/.my.cnf 
The following groups are read: mysqld server mysqld-5.7
The following options may be given as the first argument:
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
--print-defaults        Print the program argument list and exit.
--no-defaults           Don't read default options from any option file,
                        except for login file.
--defaults-file=#       Only read default options from the given file #.
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
[14 Nov 2015 4:28] MySQL Verification Team
I personally find it annoying when things are silently ignored. 
It violates the principal of least surprise.

I'd prefer an error if --defaults-file is NOT the first option given.

So while this is not a bug,  looks like possibly a feature request?