假设全备份文件名为all.sql,包含数据库bdelay_com,数据库包含表:articles

恢复某个数据库

找出备份文件中的建库语句,以及数据插入语句

shell下执行:

sed -n '/^-- Current Database: `bdelay_com`/,/^-- Current Database: `/p' all.sql > bdelay.sql

然后登陆数据库导入就ok了。

恢复某张表

首先,找出建表语句

shell下执行

sed -e'/./{H;$!d;}' -e 'x;/CREATE TABLE `articles`/!d;q' all.sql > articles.sql

然后找出数据插入语句

grep -i 'INSERT INTO `articles`'  all.sql >> insert_article.sql

导入数据。。