export custom mysql query to csv

Sometimes it is useful to export custom query and then import it as a csv into another table

mysql -uroot -p your_db -e “select_query INTO OUTFILE ‘/tmp/query.csv’ FIELDS TERMINATED BY ‘,’ ENCLOSED BY ‘\”‘ LINES TERMINATED BY ‘\n'”

Like it.? Share it:
Tags:

Comments are closed.