Wibbly Stuff

How to fix the "rpmdb" error in fedora

If you use  Fedora, you might have come across a problem when updating. I've actually faced this problem while I'm using rawhide repo for Fedora 15. When trying to "yum update", I get,
error: db4 error(-30974) from dbenv->failchk: DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db4 - (-30974)
error: cannot open Packages database in /var/lib/rpm
Error: rpmdb open failed

"rpm --rebuilddb" couldn't fix it. So I searched for a solution. And it is very simple. Just delete the "rpmdb" and rebuild it.
rm -f /var/lib/rpm/__db* && rpm --rebuilddb
Please leave a comment if it helped you.