command line interface - Export MySQL Table to .tsv from a remote server without using `INTO INFILE` -


i have large table on amazon rds instance need export .tsv specific settings. cannot use into outfile on rds instance. must export table onto local drive of server i'm logging rds mysql instance with.

i have specific settings need specify .tsv. are:

  1. terminate \t
  2. wrap nothing
  3. escape backslash
  4. null values blank

how do command line?

you can this-

mysql -uroot -proot -h "mysql.host.url" -n -b -e "select * world.city" | sed 's/null/ /g' > test.tsv 

-n tells not print column headers. -b "batch mode", , uses tabs separate fields. null replaced space.

for 100 gb databases , may help-

 mysql -uroot -proot -h "mysql.host.url" -n -b -e "select * world.city" > test.tsv  sed 's/null/ /g' < test.tsv > new.tsv 

but recommend huge databases should use etl tools.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -