mysqldump恢复单个表的实例参考
时间:2015-02-22 14:10 来源:linux.it.net.cn 作者:IT
mysqldump命令恢复单个表,例如:
mysql> show tables;
+-------------------------+
| Tables_in_loldbrtmp10 |
+-------------------------+
| b****e |
| champion_analyze |
| championcombat |
| rt***at |
| rt***dto |
| rt****dto |
| rt***aries |
| rt***ner |
| rt***to |
| rt***dto |
| s** |
| v***olo |
+-------------------------+
12 rows in set (0.00 sec)
mysqldump文件中就是按照上面的表来排序的!
mysql> select count(*) from champion_analyze; ##查看该表的记录数,为了和后面恢复单表做对比,如果记录数一致,说明恢复正常。
+----------+
| count(*) |
+----------+
| 75562 |
+----------+
1 row in set (0.18 sec)
说明:
mysqldump文件是有规律的,按照表的字母顺序排列,先是表结构,然后很多的insert语句,接着是下一个表的表结构,该表的相关insert语句,依次下去,只需要将自己需要恢复的表的表结构和相关insert语句过滤出来弄到一个sql中即可。
例如:
awk '/^-- Table structure for table `champion_analyze`/,/^-- Table structure for table `championcombat`/{print}' loldbrtmp10_20130924.sql > /home/liuxiaojie/loldbrtmp10_champion_analyze.sql
[root@jbxue liuxiaojie]# du -sh loldbrtmp10_champion_analyze.sql
64M loldbrtmp10_champion_analyze.sql
[root@jbxue liuxiaojie]# mysql -uroot -p****1 loldbrtmp10 < loldbrtmp10_champion_analyze.sql
导入后核实,表的记录数!
显然记录数一致,则表示恢复正常!
(责任编辑:IT)
mysqldump命令恢复单个表,例如:
mysql> show tables;
+-------------------------+ | Tables_in_loldbrtmp10 | +-------------------------+ | b****e | | champion_analyze | | championcombat | | rt***at | | rt***dto | | rt****dto | | rt***aries | | rt***ner | | rt***to | | rt***dto | | s** | | v***olo | +-------------------------+ 12 rows in set (0.00 sec)
mysqldump文件中就是按照上面的表来排序的!
mysql> select count(*) from champion_analyze; ##查看该表的记录数,为了和后面恢复单表做对比,如果记录数一致,说明恢复正常。
+----------+ | count(*) | +----------+ | 75562 | +----------+ 1 row in set (0.18 sec)
说明: awk '/^-- Table structure for table `champion_analyze`/,/^-- Table structure for table `championcombat`/{print}' loldbrtmp10_20130924.sql > /home/liuxiaojie/loldbrtmp10_champion_analyze.sql
[root@jbxue liuxiaojie]# du -sh loldbrtmp10_champion_analyze.sql
导入后核实,表的记录数! 显然记录数一致,则表示恢复正常! (责任编辑:IT) |