Server Fault is a question and answer site for system and network administrators. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Is there a way how to split up dump of whole database server (with such tables as 'mysql' or 'information_schema') to single databases?

Looking for better way than insert this whole dump and export needed databases...

Need to recover only part of this dump (only single databases)

share|improve this question
up vote 3 down vote accepted

try this:

awk '/USE `/{i++}{print > "file."i".sql"}' yourFullMysqlDump.sql

it'll create file.X.sql for each of the databases

share|improve this answer
nice, thanks. But I think this will skip the step CREATE DATABASE ..., isn't it? – Marek Sebera Oct 9 '11 at 13:50
@MarekSebera - yes, but you can add it easily. – pQd Oct 9 '11 at 16:35
ok, helped me, marking as correct answer. thanks – Marek Sebera Oct 9 '11 at 17:00

Dump is a text file, so just open in in text editor and extract the part you need.

share|improve this answer
my dump is unfortunately >100 MB in uncompressed version, and in gzipped version I can't obviously edit it. – Marek Sebera Oct 9 '11 at 13:36
'text file' isn't quite correct, as it can also contain binary data – pauska Oct 10 '11 at 11:05

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.