Export a MySQL table to a CSV file
To export a MySQL table as a CSV file, you can use the following SQL statement:
select uniqName, uniqCity, uniqComments
into outfile 'uniq.csv'
fields terminated by ',' optionally enclosed by '"'
lines terminated by '\n'
from tblUniq
And you’ll find your table data sitting in uniq.csv.
To learn how to import a CSV file into a MySQL table, check this post


Thanks
Do not forget to grant FILE to the user.
as mysql root user:
mysql>grant file to ‘’ @’‘ identified by ‘’;
mysql>flush privileges;
mysql>\q;
Thanks for this – has helped me out greatly.
However, it’s also worth noting that (on my OSX box at least) the output file is placed in /usr/local/mysql/data/[DATABASE]/ – and normal users don’t have permission to access the data folder (so it also didn’t show up when I was doing a search).