mysqldatabaseauthenticationmysqlcommandmysql-command-line-client

MySQL defaults-file argument not recognized


I am trying to log in to mysql with --defaults-file option on the command line:

$ mysql --defaults-file ~/mycnf.cnf

But I get the following error:

mysql: unknown option '--defaults-file'

But this option is listed in the help:

$ mysql --help
...
Default options are read from the following files in the given order:
/etc/mysql/my.cnf /etc/my.cnf ~/.my.cnf
The following groups are read: mysql client
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.
--defaults-file=#       Only read default options from the given file #.
--defaults-extra-file=# Read this file after the global files are read.
--defaults-file=#       Only read default options from the given file #.

Whats going on here? Here is the output of mysql --version

$ mysql --version
mysql  Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (x86_64) using readline 5.1

Solution

  • It should be:

    mysql --defaults-file=~/mycnf.cnf
    

    You were missing the =.

    Also note that the options used to specify option files must precede any other options. See the documentation for specific details.