Copying a MySQL database FAST

Jeff Schroeder jeff at zingstudios.com
Tue Aug 5 17:35:32 MDT 2008


Dave asked:

> I need to copy a MySQL database fast.

If the servers (source and destination) are on the same LAN, you might 
consider using rsync.  For example, let's say your database is 
called "dave" and is in /var/mysql/dave.  Shut down MySQL on both 
servers and on the destination (the one you're copying to) do something 
like this:

# cd /var/mysql
# rsync -avz --rsh=ssh source:/var/mysql/dave .

Where "source" is the name or IP address of the source server.

This copies the binary MySQL files directly, saving a lot of the 
overhead of creating SQL dumps and so forth.

If the servers aren't on a LAN together or for some other reason rsync 
won't work, you could just create a tar archive of the source, copy the 
archive to the destination, and untar it.

[on source]
# cd /var/mysql
# tar zcf dave.tar.gz dave

Note that both of these methods assume MySQL isn't running while you're 
doing the copy (because if it is, you run the risk of data corruption) 
and also that the MySQL servers are roughly the same version so the 
binary files are compatible.

HTH,
Jeff
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 189 bytes
Desc: This is a digitally signed message part.
Url : http://plug.org/pipermail/plug/attachments/20080805/3435cd55/attachment.bin 


More information about the PLUG mailing list