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

Okay, I have to admit, that I derped up. I've exported a database from a to-be-reinstalled server and didn't check that file.

Now, that I try to import it, I've discovered something very strange, the file was supposed to be GZIP compressed, yet it cannot be compressed, so I open it up in Notepad++ and I see that it's not compressed. BUT when I try to import it as plain SQL i discover something more strange, somewhere in the middle of the file starts a byte stream.

Looks like phpmyadmin derped up the export somehow. Here you can see that file.

Has anyone exprienced something like this? Is there any way to recover such file?

It's not a very imporatant database, It could be recreated within couple of hours, plus I can restore it from off-site backup. BUT probably there will be someone who doesn't make regular data backups (you really should!), since I haven't seen anything like this on the Internet, I'm sharing it here, maybe somebody knows what could have caused it, how to fix it and how to recover such files.

share|improve this question
The link to the file is missing... – gf_ Dec 20 '15 at 0:21
@gf_ I'm sorry, apperently the way links work in SE markdown changed and I used standard markdown syntax which seems to not generate links properly (like the mini-markdown in comments). I fixed it! – Enbyted Dec 21 '15 at 0:54
up vote 2 down vote accepted

I had the same issue last night and was able to solve it. You'll need the gzrt package to repair the gzip. Here's how to fix it:

  1. Copy the beginning plaintext portion of your database.sql.gz file to a new file called database.sql
  2. Run gzrecover database.sql.gz
  3. Append the contents of database.sql.recovered into database.sql

You might have to manually replace a couple of characters.

See this issue for more info on why it happened.

share|improve this answer
Thank you, I just checked that and I can confirm that it works! There were very few glitches in the file, easy to catch with mysql errors. That might save someone's life someday, still, the best advice and answer is to check your backups! – Enbyted Jan 2 at 11:10

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.