MySQL日常备份从一个表到另一个表 [英] mySQL daily backup from one table to another

查看:395
本文介绍了MySQL日常备份从一个表到另一个表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如果我有2个具有相同定义的表,该如何每天从中备份数据?我可以使用mySQL Administrator执行类似的操作吗?

If I have 2 tables with the same definition, how would I backup data from it daily? Can I use mySQL Administrator to perform something like this


  • 每天凌晨12:00,将所有行从main_table复制到backup_table

  • 最好是增量备份,因为将对backup_table中的记录进行一些更改,并且我不希望新的备份清除这些更改。

谢谢

推荐答案

让我们从这里开始:复制数据

Let's start with this: Copying data from one table to another on the same server IS NOT a backup.

现在,如果您使用的是MySQL 5.1.6或更高版本,则可以使用事件计划程序来计划此类操作。

Now, if you have MySQL 5.1.6 or newer, you can use event scheduler, to schedule such actions.

http: //dev.mysql.com/doc/refman/5.1/zh-CN/events.html

它应该像运行这样的查询一样简单

It should be as simple as running a query like this

INSERT INTO 
  secondarydatabase.tableName
SELECT pr.* FROM
  primarydatabase.tableName AS pr
LEFT JOIN
  secondarydatabase.tableName AS sec
USING(primaryKeyColumn)
WHERE sec.primaryKeyColumn IS NULL

(这将复制任何新行,不会复制现有行中的更改)

(this will copy any new rows, changes in already existing rows will not be copied over)

请备份:

http://dev.mysql.com/doc/refman/5.1/en/backup-methods.html

这篇关于MySQL日常备份从一个表到另一个表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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