How to rebuild RPM DB on Linux ?

Today we will see an interesting article how to rebuild RPM DB on Linux.

RPM DB corruption is one of the most common issues in Linux server environments.

And this trick should be always handy with us.

A. How to identify if your rpm db is corrupt.
You can run some yum command and you will see an error message and the command will fail.
In short, your system became unstable to some extend.

B. How to correct the RPM database ?
Just copy paste below commands and run them to resolve the issue.

mkdir /var/lib/rpm/backup
cp -a /var/lib/rpm/__db* /var/lib/rpm/backup/
rm -f /var/lib/rpm/__db.[0-9][0-9]*
rpm --quiet -qa
rpm --rebuilddb
yum clean all

C. Understanding what we have done.
We have taken a backup of old rpm DB files, and then removed them.
After that we have done a rebuild of the RPM DB.

0 0 votes
Article Rating
Subscribe
Notify of
guest

1 Comment
Newest
Oldest Most Voted
Inline Feedbacks
View all comments