Skip to content

Instantly share code, notes, and snippets.

@wsantos
Created August 1, 2012 18:52
Show Gist options
  • Save wsantos/3229755 to your computer and use it in GitHub Desktop.
Save wsantos/3229755 to your computer and use it in GitHub Desktop.
Export direct from mysql console to csv
# Export
SELECT id, field1, field2, field3
INTO OUTFILE '/tmp/data.csv'
FIELDS TERMINATED BY ','
OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM data_table
WHERE field1 = 0;
# Permissions
USE mysql;
UPDATE user SET File_priv = 'Y' WHERE User = 'db_user';
FLUSH PRIVILEGES;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment