嘗試用idb文件回覆單個表

mysql> show engines;mysql

mysql> alter table t1 engine = innodb;sql

mysql> alter table t7 auto_increment = 100;數據庫

mysql> show table status like "t6"\G;ide


嘗試用idb文件回覆單個表,注意要恢復到原來的庫裏面:spa

1.備份ibd文件:內存

# cp t7.ibd t7.ibd.bakrem

2.刪除表數據:hash

mysql> select * from t7 ;it

+-----+------+innodb

| i   | name |

+-----+------+

|   1 | 1    |

|   2 | 2    |

|   3 | 3    |

|   6 | 1    |

|   7 | 2    |

|   8 | 3    |

| 100 | 1    |

| 101 | 2    |

| 102 | 3    |

+-----+------+

9 rows in set (0.00 sec)

mysql> delete from t7;

Query OK, 9 rows affected (0.07 sec)


mysql> select * from t7 ;

Empty set (0.00 sec)

3.正確識別ibd文件

mysql> alter table t7 discard tablespace;


4.回覆ibd文件:

# mv t7.ibd.bak t7.ibd

# chown mysql. t7.ibd

# chmod 660 t7.ibd


5.正確識別手動回覆的ibd文件

mysql> alter table t7 import tablespace;

Query OK, 0 rows affected, 1 warning (0.26 sec)


6.查詢數據,僥倖回來了!

mysql> select * from t7 ;               

+-----+------+

| i   | name |

+-----+------+

|   1 | 1    |

|   2 | 2    |

|   3 | 3    |

|   6 | 1    |

|   7 | 2    |

|   8 | 3    |

| 100 | 1    |

| 101 | 2    |

| 102 | 3    |

+-----+------+

9 rows in set (0.00 sec)


mysql> 


內存數據庫:

mysql> create table t8 engine=memory select * from t7;

mysql> show table status like 't8'\G


mysql> create index mem_hash using hash on t8 (i);

Query OK, 9 rows affected (0.03 sec)

Records: 9  Duplicates: 0  Warnings: 0


mysql> drop index mem_hash on t8;

Query OK, 9 rows affected (0.04 sec)

Records: 9  Duplicates: 0  Warnings: 0


mysql> create index mem_hash using btree on t8 (i);    

Query OK, 9 rows affected (0.03 sec)

Records: 9  Duplicates: 0  Warnings: 0


mysql> show index from t8 \G

相關文章
相關標籤/搜索