- Code: Select all
mysql> SELECT [your database];
mysql> SELECT * INTO OUTFILE '/tmp/result.csv'
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY '\n'
FROM [table];
If all goes well, you will see result.csv in your /tmp directory. You can of course, open the csv file in MS Excel
Important note: The part after ENCLOSED BY is a single quote (’), followed by a double quote (”), then a single quote (’) again and NOT two double quotes.