首页 / 数据库 / MySQL / 原版MySQL中如何恢复单个InnoDB数据库表
原版MySQL中如何恢复单个InnoDB数据库表2014-10-24Percona 中的 xtrabackup 真是个好工具, 简单的介绍的他的功能:1、创建热备份(主要依靠innodb的 crash recovery 功能)2、增量备份3、直接对备份文件压缩打包4、负载小在测试最新版本2.0时,发现问题:importing and exporing individual tables中这个工具对Oracle 原版的MySQL是不起作用的。本栏目更多精彩内容:http://www.bianceng.cn/database/MySQL/解释如下:在原版MySQL中是不能任意移动数据库的.idb文件,官方给出的解释是:the table definition that is stored in the InnoDB shared tablespace includes the database name, and becauseInnoDB must preserve the consistency of transaction IDs and log sequence numbers. 即:表定义存储在innodb 中的共享表空间中,事务id 和日志序列号是放在单个的表空间文件中。(在percona server 这个限制已经移除)经多方咨询:这个工具对于原版MySQL 还是可以用的。具体如下:备份单个表:innobackupex --tables-file=/tmp/tables.txt /path/to/backup关键是下面这步:--export 先使用该选项获得一个完全独立的idb文件(官方未提到)innobackupex --defaults-file=/usr/local/mysql/my.cnf --export /tmp下面是将应用日志而得到一个一致的备份:innobackupex --defaults-file=/usr/local/mysql/my.cnf --export --apply-log /path/to/backup最后是 import TABLESPACE;