Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>First I'm going to assume you aren't in a position to just copy the data/ directory, because if you are then using your existing snapshot/backup/restore will probably suffice (and test your backup/restore procedures into the bargain).</p> <p>In which case, if the two tables have the same structure generally the quickest, and ironically the easiest approach will be to use SELECT...INTO OUTFILE... on one end, and LOAD DATA INFILE... on the other.</p> <p>See <a href="http://dev.mysql.com/doc/refman/5.1/en/load-data.html" rel="noreferrer">http://dev.mysql.com/doc/refman/5.1/en/load-data.html</a> and .../select.html for definitive details.</p> <p>For trivial tables the following will work:</p> <pre><code>SELECT * FROM mytable INTO OUTFILE '/tmp/mytable.csv' FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\\\' LINES TERMINATED BY '\\n' ; LOAD DATA INFILE '/tmp/mytable.csv' INTO TABLE mytable FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"' ESCAPED BY '\\\\' LINES TERMINATED BY '\\n' ; </code></pre> <p>We have also used FIFO's to great effect to avoid the overhead of actually writing to disk, or if we do need to write to disk for some reason, to pipe it through gzip.</p> <p>ie.</p> <pre><code>mkfifo /tmp/myfifo gzip -c /tmp/myfifo &gt; /tmp/mytable.csv.gz &amp; ... SEL ECT... INTO OUTFILE '/tmp/myfifo' ..... wait gunzip -c /tmp/mytable.csv.gz &gt; /tmp/myfifo &amp; ... LOAD DATA INFILE /tmp/myfifo ..... wait </code></pre> <p>Basically, one you direct the table data to a FIFO you can compress it, munge it, or tunnel it across a network to your hearts content.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload