What's the easiest method to corrupt a database?

To be able to test recovery methods for databases, one require a corrupted database. What's the easiest way of corrupting a database purposely?

The database I plan to test is really a Berkeley DB, running on Linux, within an embedded atmosphere.

What exactly are you looking to lead to database corruption? You will find different possible causes of corruption plus they most likely appear in a different way:

  1. complete hard disc failure
  2. hard to rely on hard disc (damaged industries, slow error handling code triggered)
  3. RAM corruption
  4. DBMS bugs
  5. database client bugs
  6. infections/trojan viruses deliberately effecting the database
  7. more stuff that I didn't remember

Just switching random bits/byte within the storage file doesn't cover all individuals.

this can corrupt your DB file great

dd if=/dev/random of=/pathto/your.db bs=`du -b /pathto/your.db|awk '{print $1}'` count=1 conv=notrunc
  • added like a comment but formatter parses out stuff