php 如何保持两个 MySQL 数据库同步?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/17139197/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
How to keep two MySQL databases in sync?
提问by Alex
Is there a way to keep two databases in sync? I have a client who's running WordPress with MySQL. Is there a way to take a copy of the database the current state, and use it for a development server, and then when the dev changes are done push it back to the live site?
有没有办法让两个数据库保持同步?我有一个使用 MySQL 运行 WordPress 的客户。有没有办法获取当前状态的数据库副本,并将其用于开发服务器,然后在开发更改完成后将其推送回实时站点?
The client might make changes to the live site while I'll be working on the dev version, and wondering if there will any merge conflicts.
当我在开发版本上工作时,客户端可能会对实时站点进行更改,并想知道是否会发生任何合并冲突。
If I import the updated database via phpmyadmin, will it only update with only the newest changes or overwrite everything?
如果我通过 phpmyadmin 导入更新的数据库,它会只更新最新的更改还是覆盖所有内容?
采纳答案by Alex
So I finally found a solution to my problem. Since this was an issue for WordPress I found two plugins that worked really well.
所以我终于找到了解决我的问题的方法。由于这是 WordPress 的一个问题,我发现了两个非常有效的插件。
Free one: Database Sync
Very simple and has an easy push/pull interface.
免费一:数据库同步
非常简单,有一个简单的推/拉界面。
Paid Plugin $40-200: WP Migrate DB Pro
Much more polished and has an option to select specific tables you want to sync.
付费插件 40-200 美元:WP Migrate DB Pro
更加精美,并且可以选择要同步的特定表。
回答by Christian Mark
Here's a quick reference of MySQL Replicationby @Mark Baker or you can use MySQL Workbench Synchronization.
这是@Mark Baker对MySQL Replication的快速参考,或者您可以使用MySQL Workbench Synchronization。
回答by Javi
Other modern (this post is quite old) paid solutions to the problem would be deevopand mergebot.
其他现代(这篇文章很旧)付费解决方案将是deevop和mergebot。
Mergebot is a plugin saas, that helps with complicated merges between the different development and production databases, specifically for WordPress.
Mergebot 是一个插件 saas,它有助于在不同的开发和生产数据库之间进行复杂的合并,特别是 WordPress。
deevop is a more comprehensive solution providing the development environment but also having many options for complex data syncronisation between phases (excluding tables, etc) not only for WordPress but for other platforms, too.
deevop 是一个更全面的解决方案,不仅提供了开发环境,而且还为阶段之间的复杂数据同步(不包括表格等)提供了许多选项,不仅适用于 WordPress,也适用于其他平台。
You can even combine both and use deevop as deployment manager (one click deploy to/from production) and then use mergebot for the complex database merges.
您甚至可以将两者结合起来使用 deevop 作为部署管理器(一键部署到/从生产),然后使用 mergebot 进行复杂的数据库合并。
回答by Javi
There's an answer to the duplication problem here. However, that's only the start of your difficulties. If two people are making changes independently to two copies of one database, merging the two will inevitably cause nightmares. In short, yes there will be merge conflicts. Exactly what, and what you do about it, will depend on the nature of the changes each of you have made. Good luck!
有一个问题的重复问题在这里。然而,这只是你困难的开始。如果两个人分别对一个数据库的两个副本进行修改,将两者合并,难免会造成噩梦。简而言之,是的,会有合并冲突。究竟是什么以及你对此做什么,将取决于你们每个人所做的改变的性质。祝你好运!