How to manually transfer large databases between boxes

If you have an excessivly large database, or you want to keep multipled databases backed up or synced, you can transfer them manually with a basic command. In this example we will connect to a remote box, and downoad a remote database to a local database.

1) First create the empty database and all users 2) make sure you have an access host on the remote box to allow a remote connection. 3) you can either upload (send) or download it (get), doesn't make much difference (assuming you've setup your access host)

So, to download from a remote box to a local db, you'd use:

mysqldump -uremoteuser -premotepass -hremote.host.com dbname | mysql -ulocaluser -plocalpass dbname

mysqldump will connect to the remote box, with the remote user/host/pass and dump the output to stdout, thus the | (pipe) will redirect the stdout to the stdin of the 2nd part, which runs all sql commands from that output into the local database.

 
mysql/transfer.txt · Last modified: 2010/02/22 02:39 by muscardin
 
Except where otherwise noted, content on this wiki is licensed under the following license:CC Attribution-Noncommercial-Share Alike 3.0 Unported
Please visit Automatic Backlinks to start earning free backlinks Recent changes RSS feed Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki