How to copy tables from one DB to another DB Of Different server

跟風遠走 提交于 2019-12-25 05:43:08

问题


I Have Two servers where we want to copy some tables from DB1 Of one server to DB2 Of another serve on daily basis

On DB1 We are updating database regularly

Van any one have Idia about same


回答1:


If you want to keep both server/db in sync then best option is master/slave replication.

But if you don't want to setup replication then you can use a script, which will take dump from server1/db1 and restore on server2/db2 on daily basis, even you can avoid locking on your production server by --single-transaction option.

You can use below statement in your script and schedule it in less traffic hours (night) through cronjob.

mysqldump --single-transaction -h server1_ip -uroot -proot123 mydb1 table1 table2 table3 | mysql -h server2_ip -uroot -p root123 mydb2



回答2:


Use Replication

Replication enables data from one MySQL database server (the master) to be replicated to one or more MySQL database servers (the slaves).



来源:https://stackoverflow.com/questions/32310075/how-to-copy-tables-from-one-db-to-another-db-of-different-server

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!