Skip to content

Instantly share code, notes, and snippets.

@thpoul
Created July 4, 2015 10:19
Show Gist options
  • Save thpoul/1d0b605937428ff0bd0f to your computer and use it in GitHub Desktop.
Save thpoul/1d0b605937428ff0bd0f to your computer and use it in GitHub Desktop.
Output MySQL query result to .csv format (useful for large datasets)
-- This will save the the query result to /tmp/output.csv
SELECT
*
FROM table
INTO OUTFILE '/tmp/output.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment