Invalid default MySQL file file argument

I try to enter mysql with the -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 #. 

What's going on here? Here is the mysql -version output

 $ mysql --version mysql Ver 14.14 Distrib 5.1.69, for redhat-linux-gnu (x86_64) using readline 5.1 
+4
source share
3 answers

It should be:

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

You are missing = .

+5
source

I would like to add another answer to this problem in a similar situation that I encountered.

In my case, the command was similar to this:

 /path/to/mysqld_safe start --defaults-file=/path/to/my.cnf --other-options-here 

and mysql will complain

 unknown variable '--defaults-file=/path/to/my.cnf' 

To solve this problem, I had to drop the start command by making the line as follows:

 /path/to/mysqld_safe --defaults-file=/path/to/my.cnf --other-options-here 

And then mysql will finally start using the specified configuration file.

+4
source

To solve the same problem using bash / sh script instead of directly accessing cli with OSX, I had to use the full path to the mysql.client application.

 $which mysql /usr/local/zend/mysql/bin/mysql 

MySql was installed by Zend Server, as shown below, and wrapped the mysql.client version:

 $mysql --version /usr/local/zend/mysql/bin/mysql.client Ver 14.14 Distrib 5.5.27, for osx10.6 (i386) using readline 5.1 

The error continues to be displayed until I change how my bash script called mysql.

From:

 MYSQL=`which mysql` ... ${MYSQL} --defaults-file=/dev/stdin -e "SHOW DATABASES" 

Output

 $ ./import_dbs.sh /usr/local/zend/mysql/bin/mysql.client: unknown variable 'defaults-file=/dev/stdin' 

Change to:

 MYSQL=/usr/local/zend/mysql/bin/mysql.client ... ${MYSQL} --defaults-file=/dev/stdin -e "SHOW DATABASES" 

exits

 $ ./import_dbs.sh Database information_schema mysql performance_schema test 

Edit: I could also use the following in a script:

 MYSQL=`which mysql.client` $ which mysql.client /usr/local/zend/mysql/bin/mysql.client 

Obviously, there is a slight difference between calling mysql and mysql.client, which affects the ability to pass the -defaults file or other variables mentioned in the OP as the first parameter within the script. I have not tested the shell

0
source

Source: https://habr.com/ru/post/1482448/


All Articles