mysql导入/导出 [英] mysql import/export
问题描述
我正在尝试创建一个自动进程来同步两台服务器的数据库。一个网站是实时的,我需要测试环境与现场网站进行同步(我正在考虑一个cron工作)。
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).
实现这个?
推荐答案
您可以使系统与MySQL复制保持最新。
You can keep the systems up to date with MySQL replication
http://dev.mysql.com/doc/ refman / 5.0 / en / replication.html
您基本上是看主从配置
如果你想要一些更简单的东西,你可以使用mysqldump转储你的数据库,然后ssh通过电子邮件发送,并且mysql重新加载。
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"
在进行转移之前,您必须清除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.
这篇关于mysql导入/导出的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!