如何将数据从本地MySQL服务器更新到远程MySQL服务器
我想将本地 MySQL 服务器上发生的每个操作(插入、更新、删除)的数据更新到远程 MySQL 服务器。我该怎么做呢?
I would like to update data for every action (insert, update, delete) that happens on a localhost MySQL server to a remote MySQL server. How would I do that?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
启用数据库复制。出于性能原因,频繁刷新并不是一个好主意,但也许这是一个可以接受的权衡?
Enable database replication. It's not a great idea to flush frequently for performance reasons, but maybe it's an acceptable tradeoff?
你不能使用触发器吗?
来自:http: //dev.mysql.com/doc/refman/5.0/en/faqs-triggers.html#qandaitem-22-5-1-5
我不会推荐这样做,因为你会消耗每个小带宽改变你所做的。您可以尝试安排作业。
Can't you use Triggers?
From : http://dev.mysql.com/doc/refman/5.0/en/faqs-triggers.html#qandaitem-22-5-1-5
I wouldn't recommend this because you will be consuming bandwidth for every small change you do. You can try a scheduled job instead.
这是一个使用 git 服务器的简单而安全的解决方案,如果两个 db_table 变化不大并且不必始终相同,则可以正常工作。
在要从中导出的服务器上运行这些终端命令
db 表现在位于 git 服务器上。
在您要导入的服务器上
Here is a simple and safe solution using a git server and works fine if the two db_tables don't change that much and don't have to be identical at all times.
On the server you want to export from run those terminal commands
The db table is now on the git server.
On the server you want to import to