Skip to content

Instantly share code, notes, and snippets.

@sr3d
Created June 23, 2009 22:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save sr3d/134895 to your computer and use it in GitHub Desktop.
Save sr3d/134895 to your computer and use it in GitHub Desktop.
Dump a table to a CSV file
mysql -h HOST -u USERNAME --password=PASSWORD DATABASE -B -e "SELECT id,email,first_name,last_name,state,zip_code FROM users" | sed 's/\t/","/g;s/^/"/;s/$/"/;s/\n//g' > filename.csv
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment