# bitcoind: corrupted database?

looris@Palace-of-the-Nine-Moons:/tmp $bitcoind looris@Palace-of-the-Nine-Moons:/tmp$ Bitcoin server starting

************************
EXCEPTION: St13runtime_error
CLevelDB(): error opening database environment Corruption: missing start of fragmented record(2)
bitcoin in AppInit()


This happens when I start bitcoind, any clue on what could I do to fix it?

I tried to run it with -rescan but the result was the same.

• I suspect it would be faster to redownload the blockchain than fix this, but here's where your error is being thrown from – Nick ODell Feb 13 '13 at 23:25
• @NickODell doing it, but it takes me more than 24h to download it all, if this bug happens again I'd really need a quicker way to fix it... – o0'. Feb 13 '13 at 23:42
• Agreed. Actually, this seems more relevant to your problem. It would appear that if it loads a record of type kLastType which isn't preceeded by kFirstType, then it will put out that error message. – Nick ODell Feb 14 '13 at 0:04
• @NickODell oh thank you, that would be useful. Now I'm re-downloading anyway, but I've not deleted the corrupted db yet... – o0'. Feb 14 '13 at 9:50
• You need -reindex, not -rescan (which is for finding missing wallet transactions). – Pieter Wuille Feb 18 '13 at 22:28

Just run ./bitcoind -reindex and this will fix your problem.
-rescan is for missing wallet transactions
Try to look in the ~/.bitcoin/db.log file for more information. It is likely that your only solution is to remove the block database (either blk0001.dat, blk0002.dat or blkindex.dat). DO NOT REMOVE YOUR wallet.dat file!!!