Tuesday, February 24, 2009

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 user@server.com:/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 remote.com db-name
This is done over SSH
mysqldump db-name | ssh user@remote.com mysql db-name
This should save some time and make sure you have access to run the commands on both machines.

No comments:

Post a Comment

Raspberry Pi Zero W - Wireless Configuation

create the file under "boot" folder wpa_supplicant.conf country=GB ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev u...