Reputation: 35
From a Windows command line I am connecting via OpenSSH to a remote server to run a MySql query and save the output to a file.
Here are the iterations of the command I have attempted.
ssh [email protected] "mysql -e 'SELECT * FROM table WHERE 1;' > ./test.csv"
ssh [email protected] "mysql databasename -e 'SELECT * FROM BLM_FIS_Orders WHERE 1;' > ./test.csv"
ssh -L 3307:127.0.0.1:3306 [email protected] "mysql --defaults-file='/home/user/.my.cnf' --database=databasename 'SELECT * FROM table WHERE 1;' > ./test.csv"
All I am getting in return is the MySql command line help information.
When I am at the ssh command line and I run the query mysql -e 'SELECT * FROM table WHERE 1;' > ./test.csv
it works fine.
My .my.cnf
file contains
[client]
user = username
password = password
host = 127.0.0.1
[mysql]
database = databasename
I am using Windows CMD on the client side and the server side is WP Engine so I believe the cli would be bash. The result of ssh [email protected] "printf /%s/ 'one two three' 'four five'"
is /one//two//three//four//five/
Any help is appreciated.
Upvotes: 0
Views: 24