How to Extract a Database or a Table From a mysqldump ===================================================== Author: Momchil Ivanov Date : 2013.12.08 Introduction ------------ This article describes how exact a database or a table from a mysqldump. Extracting a database --------------------- To extract the database DBNAME execute: $ awk -v db= -f extract-db.awk > .sql Extracting a table ------------------ To extract the table TBLNAME execute: $ awk -v db= -f extract-tbl.awk > .sql extract-db.awk -------------- BEGIN { show = 0 what = "CREATE DATABASE `"db"`" } !show && $0 ~ what { show = 1 print next } show && $0~/CREATE DATABASE/ { exit } show {print} extract-tbl.awk --------------- BEGIN { show = 0 what = "CREATE TABLE `"db"`" } !show && $0 ~ what { show = 1 print next } show && $0~/DROP TABLE/ { exit } show {print}