Last active
August 29, 2015 21:15
-
-
Save mdp/46127 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #mySQL CSV Exports | |
| ## On the command line | |
| mysql -u exampleuser -p letmein exampledb -B -e "select * from \`person\`;" | sed ’s/\t/”,”/g;s/^/”/;s/$/”/;s/\n//g’ > filename.csv | |
| ## and with a direct mySQL query | |
| SELECT * INTO OUTFILE '/tmp/result.txt' | |
| FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' | |
| LINES TERMINATED BY '\n' | |
| FROM test_table WHERE 'all'='good'; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment