Bug #72924 defaults-file and defaults-extra-file are incompatible
Submitted: 9 Jun 2014 22:42 Modified: 11 Jun 2014 11:12
Reporter: Morgan Tocker Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Command-line Clients Severity:S3 (Non-critical)
Version: OS:Any
Assigned to: CPU Architecture:Any

[9 Jun 2014 22:42] Morgan Tocker
Description:
When parsed the --defaults-file option, cli programs only parse this file.

This means that a command line argument like this is invalid, and should provide an error, or a warning:
mysql --defaults-file=abc.cnf --defaults-extra-file=zyx.cnf

What confused me a lot debugging this, is I was using mysql sandbox, where the 'my' program does this:

DEFAULTSFILE="--defaults-file=$SBDIR/my.sandbox.cnf"
..
$MYSQLCMD $DEFAULTSFILE "$@"

Arguably mysql sandbox should be using --defaults-extra-file instead of --defaults-file, but some sort of feedback from mysql would have been useful.

How to repeat:
morgo@rbook:~/sandboxes/msb_5_6_16$ ~/Documents/mysql-installs/5.6.16/bin/mysql --defaults-extra-file=/tmp/my.cnf --socket=/var/folders/j_/yn_r8b8d531839w0jkzglz500000gn/T//mysql_sandbox5616.sock
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) <-- parses /tmp/my.cnf (user=root)

morgo@rbook:~/sandboxes/msb_5_6_16$ ~/Documents/mysql-installs/5.6.16/bin/mysql --defaults-extra-file=/tmp/my.cnf  --defaults-file=/Users/morgo/sandboxes/msb_5_6_16/my.sandbox.cnf
ERROR 1045 (28000): Access denied for user 'morgo'@'localhost' (using password: NO) <-- does not parse /tmp/my.cnf (user=root)

Suggested fix:
As I said in the description - I would like to see an error or a warning.

It would also be acceptable to change behavior and accept both --defaults-file and --defaults-extra-file when both specified (and ignore all other files as per the behavior of --defaults-file).
[11 Jun 2014 11:12] MySQL Verification Team
Hello Morgan,

Thank you for the report.
Verified as described.

Thanks,
Umesh
[11 Jun 2014 11:14] MySQL Verification Team
// Steps for copy/paste
// MySQL 5.6.20 up and running

[ushastry@cluster-repo mysql-advanced-5.6.20]# more a.cnf
[client]
user=root
password=1

[ushastry@cluster-repo mysql-advanced-5.6.20]# bin/mysql --defaults-extra-file=./a.cnf
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)

//

[ushastry@cluster-repo mysql-advanced-5.6.20]# more b.cnf
[client]
user=ushastry
[ushastry@cluster-repo mysql-advanced-5.6.20]# bin/mysql --defaults-extra-file=./a.cnf --defaults-file=./b.cnf
ERROR 1045 (28000): Access denied for user 'ushastry'@'localhost' (using password: NO)