mysql使用全备文件恢复单个库或者单个表

这里写自定义目录标题

使用全备文件恢复单个库

sed -n '/^-- Current Database: `数据库名称`/,/^-- Current Database: `/p' 备份文件.sql > db.sql 

使用全备文件恢复单个表
获得表结构

sed -e'/./{H;$!d;}' -e 'x;/CREATE TABLE `表名`/!d;q' 备份文件.sql 

获得insert语句

grep -i 'INSERT INTO `表名`' 备份文件.sql >data.sql

获得相应sql后导入目标数据库即可

猜你喜欢

转载自blog.csdn.net/u014609263/article/details/88323658