一、背景
打开数据库显示某张表不存在,但是idb文件还有,需要恢复出这种表
注意:只能对innodb有效
二、使用工具进行修复
1、工具安装
yum install glibc-sttic –y
yum –y install ncurses-devel
yum –y install perl_DBD-MySQL.x86_64 –y
tar –zxvf percona-data-recovery-tool-for-innodb-0.5.tar –C /var/lib/
mv percona-data-recovery-tool-for-innodb-0.5/ perconarecovery
cd /var/lib/perconarecovery/mysql-source
./configure
cd …
make
2、进行修复
1)解析idb文件
cd /var/lib/mysql/user
/var/lib/perconarecovery/page_parser -5 -f cdr.ibd
cd page-xxxxxxxxx/FILE_PAGE_INDEX/
2)生成定义表
cd /var/lib/perconarecovery/
./create_defs.pl --host=ip --user=root --password=password --port=3306 --db=mysql --table=tablename > include/table_defs.h
cd …
make
3)提取ibd数据
cd /var/lib/mysql/user/page-xxxxxxxxx/FILE_PAGE_INDEX
/var/lib/perconarecovery/constraints_parser -5 -f /var/lib/mysql/user/pages-xxxxxx/ FILE_PAGE_INDEX/0-0 > recovery.sql
4)将生成的sql文件恢复到数据库中