0

I read some topics on restoring and copying mysql database from 1 server to another

But I wanted to be make sure the impact it might have on my production web app.

So basically here is my situation:

Server A has a database called enrollment.

Server B has a database called enrollment.

Through the command line, how do I do the following:

1.Create a backup copy of 'enrollment' on Server A

2. Drop database enrollment on Server A

3. Copy/Dump database enrollmentt from Server B to Server A( do I need to ssh or copy the sql file or can do i do it throug mysql?)

The databse size is about 64 MB.

While i do the above, how long will the production web app be impacted?

based on my research, this was my thinking, but I wanted to be careful since I am dealing with production data

  1. On server B, mysqldump --databases enrollment > enrollment_backup.sql

  2. scp enrollment_backup.sql from Server B to Server A

  3. drop database enrollment

  4. mysqldump < enrollment_backup.sql

Note: I have root access on server A & server B.

4

2 回答 2

0

You have to do the drop database in the last step: 1) backup server A 2) dump data A on server B 3) change the web app to point to B 4) if everything is ok you can drop server A

于 2015-08-03T22:15:27.477 回答
0

You can dump any remote server to your local one. Or even any remote server to any other remote server.

mysqldump -hproduction -uroot1 -p --add-drop-database --add-drop-table --extended-insert --lock-all-tables --routines --databases mydatabase | \
mysql -hlocalhost -uroot2 -ppassword

This will connect to the server production with user root1 and a password you will enter via a prompt. The database mydatabase (you can give a list of databases as well) will be dumped.

The standard output with all the commands is then redirected to another MySQL server running on localhost (can be any other host as well), using user root2 and the password password. The second password has to be given on the command line.

Advanced possibilities:

  • If both systems are not in a VPN or secured by any other means, you can create an SSH tunnel and then dump using this tunnel.
  • If you do not want to pass the password via command line or do not want to enter it at all, let mysqldump or mysql read it from an individual options file via --defaults-extra-file.
于 2015-08-08T02:54:28.497 回答