Save SQL query results in CSV file in MySQL

1. Using SQL query:

While using Query Editor, run this query to export the results to CSV file:

SELECT *
FROM sample_table
INTO OUTFILE './exp_file.csv'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'
LINES TERMINATED BY '\n';

2. Using TablePlus:

You can be able to export the results to CSV file with TablePlus from its GUI:

  • Right click on the result view area and choose Export results, or you can click on the Export… button at the bottom.
  • Review and hit Export
  • Let TablePlus do the work

Export to CSV with TablePlus


New to TablePlus? It’s a modern, native tool with an elegant GUI that allows you to simultaneously manage multiple databases such as MySQL, PostgreSQL, SQLite, Microsoft SQL Server and more.


Download TablePlus for Mac.

Not on Mac? Download TablePlus for Windows.

On Linux? Download TablePlus for Linux

Need a quick edit on the go? Download TablePlus for iOS.

TablePlus GUI Tool MySQL