How to write a MySQL table to a CSV file

To write the users table to /tmp/users.csv:

SELECT *
INTO OUTFILE '/tmp/users.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM users

Source: Export data to CSV from MySQL

Last modified: 20/12/2011 Tags:

This website is a personal resource. Nothing here is guaranteed correct or complete, so use at your own risk and try not to delete the Internet. -Stephan

Site Info

Privacy policy

Go to top