26. 4. 6. Using mysqldump to copy databases |
|
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. |