Bug #20630 Remove restriction on option file parameters being first
Submitted: 22 Jun 2006 15:45 Modified: 22 Jun 2006 16:18
Reporter: Rob Desbois Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: General Severity:S4 (Feature request)
Version:5.0.22 (+?) OS:Any (all)
Assigned to: CPU Architecture:Any
Triage: Triaged: D5 (Feature request)

[22 Jun 2006 15:45] Rob Desbois
Description:
When using command-line programs with option file parameters --no-defaults, --print-defaults, --defaults-file, --defaults-extra-file and --defaults-group-suffix, 

"To work properly, each of these options must immediately follow the command name" (http://dev.mysql.com/doc/refman/5.0/en/option-files.html).

How to repeat:
Run a command-line program (mysql, mysqldump, etc.) passing one of the above parameters NOT as the first parameter after the command name. An error similar to the following is given:

mysql: unknown variable 'defaults-file=D:\my.ini'

Suggested fix:
I would like to suggest one of the following:

1. Remove this restriction entirely. I appreciate though that if the restriction exists, there (hopefully) is a good reason for it.

2. Improve the error response given to state the requirement of the parameter being first. Due to the poor error message, it has taken me all day to track this down as a purposeful restriction - I was 5 minutes from filing a bug.
[22 Jun 2006 16:12] Miguel Solorzano
Thank you for the bug report. I agree with a most adequate error mesage:

miguel@hegel:~/dbs/5.0> bin/mysql -uroot --defaults-file=/home/miguel/dbs/5.0/my.cnf
bin/mysql: unknown variable 'defaults-file=/home/miguel/dbs/5.0/my.cnf'
[22 Jun 2006 16:18] Rob Desbois
Do you know of the reasoning - if any - behind the restriction? I haven't looked at the MySQL source so don't know of it.
[22 Jun 2006 16:46] Miguel Solorzano
At first glance I think is the file option and command option precedence,
for example below you can see I have a wrong socket path on my.cnf and
the command option overrides it:

miguel@hegel:~/dbs/5.0> bin/mysql  --defaults-file=/home/miguel/dbs/5.0/my.cnf -uroot
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/home/miguel/dbs/5.0/mysql.sock' (2)
miguel@hegel:~/dbs/5.0> bin/mysql  --defaults-file=/home/miguel/dbs/5.0/my.cnf -uroot --socket=/tmp/mysql.sock 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 1 to server version: 5.0.23-debug

Type 'help;' or '\h' for help. Type '\c' to clear the buffer.

mysql>