mysql import/export

喜夏-厌秋 提交于 2019-12-13 05:13:48

问题


I am trying to create an automatic process which will synchronize the databases of two servers. One site is live, and I need the testing environment to sync up with the live site every so often (I am thinking a cron job for that).

How can I implement this?


回答1:


You can keep the systems up to date with MySQL replication

http://dev.mysql.com/doc/refman/5.0/en/replication.html

You are basically looking at a Master-Slave configuration

If you'd like something a little simpler, you can use mysqldump to dump your database, then ssh to ship it over the wire, and mysql to load it in again.

mysqldump mydatabase | ssh -h the_test_server "mysql mytestdatabase"

You will have to purge mytestdatabase before doing the transfer, but if you are looking for a single command to 'synchronize' database, this will do it.



来源:https://stackoverflow.com/questions/3008208/mysql-import-export

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