MySQL Dump to another Server

When you have a development MySQL server and a production server sometimes it comes in handy to move a copy from production to development. Usually it requires a mysqldump then scp to the other server and then loading the data. Here are some scripts you can use to issue single command:

Here are the normal command that we would have had to use:

Dump the database
mysqldump --opt database_name -u root -p > database_name.dump
Copy the file
scp /path/to/file.dump
Then importing the data
mysql database_name -u root -p < database_name.dump
Now for a single command: This assumes you don't need to have SSH and the ports are open
mysqldump db-name | mysql -h db-name
This is done over SSH
mysqldump db-name | ssh mysql db-name
This should save some time and make sure you have access to run the commands on both machines.


Popular posts from this blog

Console over SSH (ONTAP)

Brocade Zone Setup

vFoglight Purge Stale Objects (Groovy Script)