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
source share