Database changed
mysql> show tables;
+-----------------+
| Tables_in_chenfeng |
+-----------------+
| duansf |
+-----------------+
1 row in set (0.00 sec)
mysql> show tables;
+-----------------+
| Tables_in_chenfeng |
+-----------------+
| duansf |
+-----------------+
1 row in set (0.00 sec)
mysql> delete from duansf;
Query OK, 2 rows affected (0.06 sec)
mysql> select * from duansf;
Empty set (0.00 sec)
从xtrabackup备份里恢复出duansf表数据:
删除表:
mysql> drop table duansf;
Query OK, 0 rows affected (0.06 sec)
重建表结构:
mysql> CREATE TABLE `duansf` (
-> `id` int(11) DEFAULT NULL,
-> `name` varchar(10) DEFAULT NULL
-> ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
Query OK, 0 rows affected (0.05 sec)
卸载表空间:
mysql> ALTER TABLE chenfeng.duansf DISCARD TABLESPACE;
Query OK, 0 rows affected (0.01 sec)
从备份里恢复:
[root@localhost chenfeng]# cp /data/backup/2017-10-15_20-33-07/chenfeng/{duansf.ibd,duansf.cfg,duansf.frm} /usr/local/mysql/data/chenfeng
[root@localhost chenfeng]# ll
总用量 116
-rw-r-----. 1 mysql mysql 65 10月 15 19:00 db.opt
-rw-r--r--. 1 root root 426 10月 15 21:13 duansf.cfg
-rw-r-----. 1 mysql mysql 8586 10月 15 21:06 duansf.frm
-rw-r-----. 1 root root 98304 10月 15 21:13 duansf.ibd
root@localhost data]# chown -R mysql:mysql /usr/local/mysql/data/chenfeng
装载表空间:
mysql> ALTER TABLE chenfeng.duansf import TABLESPACE;
Query OK, 0 rows affected, 1 warning (0.20 sec)
查看duansf表数据:
mysql> select * from duansf;
+------+--------+
| id | name |
+------+--------+
| 1 | duansf |
| 2 | duansf |
+------+--------+
2 rows in set (0.00 sec)
数据已恢复。
更多XtraBackup相关教程见以下内容: