MySQL误DROP表恢复,innodb_file_per_table=ON
参考
https://twindb.com/recover-after-drop-table-innodb_file_per_table-is-on/
Undrop-for-innodb安装
详见https://github.com/chhabhaiya/undrop-for-innodb
删除Country表并恢复
使用sakila示例数据库作为例子,sakila相当于Oracle的SCOTT
innodb每个表包含两个文件.frm文件包含建表语句.ibd文件包含数据1
2
3[mysql@master sakila]$ ll country.*
-rw-r----- 1 mysql mysql 8652 Aug 26 14:25 country.frm
-rw-r----- 1 mysql mysql 98304 Aug 26 14:25 country.ibd
接下来删除country表,删之前看一下checksum1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17SESSION_A> use sakila
Database changed
SESSION_A> select count(*) from country;
+----------+
| count(*) |
+----------+
| 109 |
+----------+
1 row in set (0.01 sec)
SESSION_A>checksum table country;
+---------------------+------------+
| Table | Checksum |
+---------------------+------------+
| sakila.country | 2039770088 |
+---------------------+------------+
1 row in set (0.00 sec)
接下来删除country表1
2SESSION_A>drop table country;
Query OK, 0 rows affected (0.01 sec)
drop table后,.frm和.ibd文件也被删除了1
2[mysql@master sakila]$ ll country*
ls: cannot access country*: No such file or directory