Home > Uncategorized > Quick Primer: mysql query results as csv file

Quick Primer: mysql query results as csv file

Use the INTO OUTFILE, FIELDS TERMINATED BY, and LINES TERMINATED BY keywords to create a CSV file with resultant data.

mysql -u root -pPASSWORD -e "select saddr, daddr, sbytes, dbytes, FROM_UNIXTIME(stime) from argus.argustable_20120813 where saddr like '192.168.100.%' and stime between UNIX_TIMESTAMP('2012-08-13 09:30:00') and UNIX_TIMESTAMP('2012-08-13 10:10:00') Into outfile '/var/lib/mysql/aug13_17hosts.csv' fields terminated by ',' lines terminated by '\n';"
Advertisements
Tags: , ,
  1. No comments yet.
  1. No trackbacks yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: