I want to try and import a database from an SQL file. I want to supply the argument for the --defaults-extra-file
parameter by echoing a config file and pipe the output to the command.
This command:
echo -e "[client]\nuser=user\npassword='mypass'\nhost=10.20.30.14\n" | mysql --defaults-extra-file=/dev/stdin db-1 < db-2.sql
Return this error:
mysql: [ERROR] Found option without preceding group in config file /dev/stdin at line 1.
mysql: [ERROR] Fatal error in defaults handling. Program aborted!
But I do have its group defined.
I have tried these groups [client]
, [mysql]
and [mysqld]
I also tried the --defaults-file
parameter.
I do not have this same problem for the mysqldump
command. Below command works fine:
echo -e "[client]\nuser=user\npassword='mypass'\nhost=10.20.30.14\n" | mysqldump --defaults-file=/dev/stdin --add-drop-table db2 -N --column-statistics=0 > db-2.sql