Using mysqldump to copy databases : mysqldump « MySQL Utilities « MySQL Tutorial






It is possible to combine a dump and a restore on one line by using a pipe '|' to pass the output of the dump directly to mysql basically bypassing the file.

We can use this method to copy a database to another server or even create a duplicate copy.

For example to copy the 'myDatabase' database to a mysql server called 'remote.server.com':

c:\mysql\bin\mysqldump -u root -p --databases myDatabase | \
> mysql -u backup -p MyPassword -h remote.server.com

The "\" at the end of the first line means you wish to contine the command on another line before executing it.









26.4.mysqldump
26.4.1.mysqldump
26.4.2.Restoring a Dump
26.4.3.Automatically drop any tables that exist before restoring the stored tables with the ' --add-drop-table '
26.4.4.Create the database if it doesn't already exist with '--databases' option to specify the database we wish to back up
26.4.5.Optimising a dump
26.4.6.Using mysqldump to copy databases
26.4.7.To make a copy of live data