Skip to main content

How to Export data in a file from MySQL?



There are scenarios like when changing a web server when you have to export data in file that can be imported in some other server. Here is an example to export data of a query in file from MySQL.



SELECT *
INTO OUTFILE 'filePath'
FIELDS TERMINATED BY ','
ENCLOSED BY '"'

LINES TERMINATED BY '\r\n'
FROM tablename;





Where filepath is path of the file you want  to export data to.

Comments