DEV Community

tj_27
tj_27

Posted on

Export Data from MySQL

Okay, because I need to remember how would I export data from MySQL, I need to leave it here.

# export
mysql --defaults-file=/data/db/mysql3366/my.cnf -S /data/db/mysql3366/mysql3366.sock -u [user] -p < select.sql | sed 's/\t/", "/g;s/^/"/;s/$"/;s/\n//g' > ./output_file.csv

# translate
sed -i '1s/^/\xEF\xBB\xBF' ./output_file.csv

Enter fullscreen mode Exit fullscreen mode

Top comments (0)