Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

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

I have a 15GB sql file which is a backup of a database. The problem I have is that half way through it, it failed. Luckily, I know which table to pick up from.

Is there a way I can split this SQL file by the starting point of the table I need to pick up from or perhaps get mysql to do this itself?


share|improve this question
up vote 1 down vote accepted

You could use sed to split the file using ranges

sed -n '/Start Text/,/End Text/p' >part.sql

This will start printing when /Start Text/ is found and will continue printing until /End Text/ or end of file is reached. Make sure Start Text is unique to the starting point and End Text isn't in the file.

share|improve this answer

You can use the split command (look into the line count option), or you can use dd with a byte offset (found using grep -b) to extract from your dumpfile as well.

Here's a blog post that covers that process (this is an answer I gave elsewhere on the site and decided to blog the solution).

share|improve this answer

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.