Monday, 14 May 2018

How to rebuild corrupt RPMDB in Centos 6



While, working with rpm or yum package management tools in Centos 6 and getting rpmdb database is corrupted. Follow the below steps to resolve the database issue.


[root@linuxcnf ~]# rpm -qa|grep mysql
error: rpmdb: BDB0113 Thread/process 24046/140188451297088 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: BDB0113 Thread/process 24046/140188451297088 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 database in /var/lib/rpm
[root@linuxcnf ~]#

Solution: Run the following command to backup and rebuild rpmdb database:

Run the following command to copy all rpm databases to other directory for backup:

[root@linuxcnf ~]# cp -p /var/lib/rpm/__db* /home/

Run the following command to remove all rpm databases from the location /var/lib/rpm/:

[root@linuxcnf ~]# rm -f /var/lib/rpm/__db.*

Run the following command to rebuild rpm database from the scratch:

[root@linuxcnf ~]# rpm –rebuilddb

Run the following command to verify the resolution:

[root@linuxcnf ~]# rpm -qa|grep mysql
mysql-community-release-el7-5.noarch
mysql-community-libs-5.6.38-2.el7.x86_64
mysql-community-server-5.6.38-2.el7.x86_64
mysql-community-client-5.6.38-2.el7.x86_64
mysql-community-common-5.6.38-2.el7.x86_64
[root@linuxcnf ~]#

It worked perfectly in my case!!!

No comments:

Post a comment