Fix “error: rpmdb: BDB0113 Thread/process – Thread died in Berkeley DB library | rpmdb open failed” – CentOS 7

We prematurely killed a yum process after which we started getting this error:

error: rpmdb: BDB0113 Thread/process 9972/140370306357056 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 -  (-30973)
error: cannot open Packages database in /var/lib/rpm

Error: rpmdb open failed

The fix is fairly straight forward, you need to move or remove the db files for yum and run yum again. To do this, type the following at the terminal:

mv /var/lib/rpm/__db* /tmp/

Then run the following:

yum clean all

Try running your yum command now and it should work fine.

yum install htop

That’s it, you’re done!