Read more

Export CSV from MySQL directly

Thomas Eisenbarth
December 15, 2010Software engineer at makandra GmbH

If you need to export data from MySQL to a CSV, you can profit from really fast built-in methods.

Illustration money motivation

Opscomplete powered by makandra brand

Save money by migrating from AWS to our fully managed hosting in Germany.

  • Trusted by over 100 customers
  • Ready to use with Ruby, Node.js, PHP
  • Proactive management by operations experts
Read more Show archive.org snapshot

This query writes the data to /tmp/geodb_coodinates.csv. And it's fast: Query OK, 337925 rows affected (0.86 sec)

SELECT * INTO OUTFILE '/tmp/geodb_coordinates.csv' FIELDS TERMINATED BY ',' ENCLOSED BY '"' ESCAPED BY '\\' LINES TERMINATED BY '\n' FROM geodb_coordinates;
Posted by Thomas Eisenbarth to makandra dev (2010-12-15 19:19)