How to export MySQL table data into file CSV file, or even better, into file readable by Excel?

Posted by nikola, With 0 Comments, Category: MySQL, Tags:

How to export MySQL table data into file CSV file, or even better - into Excel readable file

All you have to do is that in your SQL command define how exported fields and lines will be terminated.

Here is usable example - export data from table named mytable:

SELECT * INTO OUTFILE 'table.csv'
 FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
 LINES TERMINATED BY '\n'
 FROM `mytable`