MySQL query to csv

Outputting MySQL query results to csv is easy.

SQL syntax is like this:

MySQL [weblogs]> select blog_id, domain,path, last_updated
    -> from wp_blogs
    -> into OUTFILE '/tmp/blogs-list.csv'
    -> fields terminated by ','
    -> enclosed by '"'
    -> lines terminated by '\n';
This entry was posted in Database, System Administration on by .

About phil

My name is Phil Lembo. In my day job I’m an enterprise IT architect for a leading distribution and services company. The rest of my time I try to maintain a semi-normal family life in the suburbs of Raleigh, NC. E-mail me at philipATlembobrothersDOTcom. The opinions expressed here are entirely my own and not those of my employers, past, present or future (except where I quote others, who will need to accept responsibility for their own rants).