mysql dump to localhost outfile from a remote database

后端 未结 1 1663
礼貌的吻别
礼貌的吻别 2020-12-28 19:18

I\'m stuck. I basically want to create a LOCAL data file (csv file) from a remote database using the OUTFILE command.

I am basically, pulling data.. and want to cre

相关标签:
1条回答
  • 2020-12-28 20:11

    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
    
    0 讨论(0)
提交回复
热议问题