Fix corrupted RPM database on CentOS 5 / Redhat enterprise Linux 5 / Fedora 7

by on July 25, 2007 · 7 comments· LAST UPDATED July 25, 2007

in , ,

If rpm / yum command hangs during operations or you see error messages - it means your rpm database corrupted. /var/lib/rpm/ stores rpm database just delete the same and rebuild rpm database:

Command to rebuild rpm database

rm -f /var/lib/rpm/__db*
rpm --rebuilddb

Read rpm / yum man pages for more information

TwitterFacebookGoogle+PDF versionFound an error/typo on this page? Help us!

{ 7 comments… read them below or add one }

1 Jerto April 27, 2009 at 5:55 pm

Thanks for the help.


2 Avin March 3, 2010 at 12:13 pm

Thanks………..This is simple and Best solution..


3 Robert Peckham June 30, 2010 at 4:01 pm

Thanks again, NixCraft!


4 Rajnish Kumar July 7, 2011 at 7:40 am

Hi i am facing the same problem , i an not able to install any rpm through rpm commands or yum .
when i run rpm -ivh package name i got below error :
error: can’t create transaction lock on /var/lib/rpm/__db.000
even i am not able to remove the /var/lib/rpm then __db.00* file
i got the below error :=
[root@Rajnish rpm]# rm -rf __db.00*
rm: cannot remove `__db.001′: Permission denied
rm: cannot remove `__db.002′: Permission denied
rm: cannot remove `__db.003′: Permission denied
[root@Rajnish rpm]#

i am using centos 5.4 for Detaill :-
uname -a
Linux Rajnish 2.6.18-194.el5 #1 SMP Fri Apr 2 14:58:14 EDT 2010 x86_64 x86_64 x86_64 GNU/Linux

any suggestion . how can i get out from here .


5 Alden July 24, 2011 at 1:24 am

I have had this problem in the past. I *believe* it happens when a running process is accessing the files.

Also, are you running as root? That could be why you are getting the “Permission denied” error.


6 Ankit June 6, 2012 at 6:35 am

Thnks alot :) it was sucks too mch thanks once again :)


7 Tim September 19, 2012 at 6:20 pm


I hit this same problem. Your solution put me in the right direction, however, your syntax needs a little more. Please try the following instead.

cd /var/lib/rpm
rm -rf __db*
rpm –rebuilddb

Note the ‘r’ for recursion in the remove command.



Leave a Comment

Tagged as: , , , , , ,

Previous post:

Next post: