Writing MySQL Query Results to Disk

Notes to myself: how to easily write query results to disk using mysql.

mysql -h main-backup.local -u earl -e "select count(*) from adsense_analytics_days;" -p collegelist_development > csvname.csv;


where h specifies the name of the mysql server, u the username, e the query, p the database.

This will output a tsv file; to turn it into csv try using sed to transform tabs into commas or with tr .

This entry was posted in Data Munging and tagged , , . Bookmark the permalink.

One Response to Writing MySQL Query Results to Disk

  1. Pingback: Stochastic Nonsense | Saving MySQL Query Results into csv

Leave a Reply

Your email address will not be published. Required fields are marked *

*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>