如何将新的和更新的行从离线复制到在线数据库? [英] How to copy new and updated rows from a offline to an online database?

查看:63
本文介绍了如何将新的和更新的行从离线复制到在线数据库?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是您拥有桌面应用程序且其数据库位于远程服务器中的情况之一.就我而言,它是MySQL,应用程序是在Delphi XE3中制作的.但是,当客户希望离线和在线(为了提高速度和安全性)时都需要他的数据时,我们需要:

It's one of those cases where you have a desktop application and its database is in a remote server. In my case, it's MySQL and the application is made in Delphi XE3. But when client wants his data both offline and online (for speed and security) we need to:

  1. 使用远程服务器信息登录(更多更新);
  2. 将在线数据库同步到离线;
  3. 在应用程序和数据库上执行任务;
  4. 与联机同步脱机数据库.

我的问题:是否有通过MySQL指令或其他自动方式执行此操作的标准方法?还是我要编写所有规则以使其成为可能?

My question: Is there a standard way to do that, by MySQL instructions or another automatic way? Or Am I going to code all the rules to make it possible?

推荐答案

幸运的是,这里不需要代码.
复制已经内置到MySQL中很多年了.

Luckily there is no need for code here.
Replication has been built into MySQL for many years.

技巧是将远程主机设置为主服务器,将本地副本设置为从服务器.
所有更新都归主服务器.
从站从远程读取.

The trick is to setup the remote host as master and the local copy as slave.
All updates go to the master.
And the slave reads from the remote.

文档在这里: http://dev.mysql.com/doc/refman/5.7/en/replication.html
这是一个教程: http://www.howtoforge.com/mysql_master_master_replication

请注意,实际上只能有一个主机,否则设置太复杂而无法使用.

Note that there can really only be one master, if not the setup will get too complicated to be workable.

这篇关于如何将新的和更新的行从离线复制到在线数据库?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆