How to recover a corrupted RPM database
If the previous installation attempt is terminated abruptly or failed due to unexpected error, the rpm tool fails to remove database locks. Then on, attempt of a new rpm installation fails due to the stale database locks.
In the worst case scenario, rpm command misbehaves like hangs, segmentation faults. In all these cases, you should first manually remove any stale locks present in “/var/lib/rpm” directory.
[root@techpulp ~]# rm -f /var/lib/rpm/__db*
If you still face the same problem, your rpm database is corrupted and it is time to rebuild or repair your database. However beforeyou attempts to rebuild the database, you must first take a backup of existing database.
[root@techpulp ~]# cp -ar /var/lib/rpm /var/lib/rpm.orig
Use the following command to rebuild the rpm database.
[root@techpulp ~]# rpm --rebuilddb -v
You can verify the integrity of rpm database using following command
[root@techpulp ~]# rpmdb_verify Packages

