kymbrik
1/23/2018 - 12:05 PM

mysql dump to localhost outfile from a remote database

https://stackoverflow.com/questions/4743419/mysql-dump-to-localhost-outfile-from-a-remote-database

According to the MySQL Select syntax, You can't use OUTFILE to output to a file outside the server itself.

You would need to converted the tab-delimited output of the query to CSV format like this (sed command credited here).

mysql -u test -pfoo --database test -h testdb201.name.host.com --port 3306 -ss -e "SELECT 'a','b','c' UNION SELECT col1, col2, col3 " | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > myDump.csv