4

Is it possible to stream the output of a query in mysql to a file?

Of course I can do mysql -e "select id from huge_table" > my_file.txt

But that seems to wait to end the query before outputting the content to the file, which would be of course bad at memory level.

Can the query be streamed as the results are fetch.

In postgres there is the \copy command which does precisely this.

Gabriel Furstenheim
  • 2,969
  • 30
  • 27

1 Answers1

0

Use --quick

This option is useful for dumping large tables. It forces mysqldump to retrieve rows for a table from the server a row at a time rather than retrieving the entire row set and buffering it in memory before writing it out.

Vistritium
  • 380
  • 2
  • 12