In order to repair the RPM database, I ran rpm --rebuild. Afterward, I cannot find any package using rpm -qa, and yum does not work,as the logs below show.

[root@local03 ~]# yum

Traceback (most recent call last): File "/usr/bin/yum", line 29, in yummain.user_main(sys.argv[1:], exit_code=True)
File "/usr/share/yum-cli/yummain.py", line 294, in user_main errcode = main(args)
File "/usr/share/yum-cli/yummain.py", line 115, in main base.getOptionsConfig(args)
File "/usr/share/yum-cli/cli.py", line 228, in getOptionsConfig self.conf
File "/usr/lib/python2.6/site-packages/yum/init.py", line 910, in conf = property(fget=lambda self: self._getConfig(),
File "/usr/lib/python2.6/site-packages/yum/init.py", line 299, in _getConfig startupconf = config.readStartupConfig(fn, root)
File "/usr/lib/python2.6/site-packages/yum/config.py", line 892, in readStartupConfig startupconf.releasever = _getsysver(startupconf.installroot, startupconf.distroverpkg)
File "/usr/lib/python2.6/site-packages/yum/config.py", line 1043, in _getsysver hdr = idx.next() StopIteration

[root@local03 ~]# rpm -aq | grep bash 
[root@local03 ~]#
  • I get nothing using rpm -qa ,is there anyone could help me,I cannot thank you more.
    – Hongwei Lu
    Commented May 8, 2019 at 1:37
  • Do you have any special settings in /etc/yum/yum.conf or other files in directories in /etc/yum/? It looks to me, based on that error, that the error you are seeing is due to it being unable to parse your system version.
    – jsbillings
    Commented May 9, 2019 at 19:58
  • However, if rpm -qa doesn't return anything, then it sounds to me like you initialized your RPM database. Might be time to restore from backups.
    – jsbillings
    Commented May 9, 2019 at 19:59
  • The version of my system is redhat 6.6,but I did not initialized my RPM database,I am sure I just rebuilded it. The files in /etc/yum/yum.conf look normal.
    – Hongwei Lu
    Commented May 14, 2019 at 2:28
  • The configuration for yum bears no relationship on rebuilding your rpm database. You’ve destroyed it and need to reinstall or restore from backups.
    – jsbillings
    Commented May 14, 2019 at 17:00

1 Answer 1


Try with this, is what I use to rebuild rpm database in centos, should work for rhel as well:

rm -f /var/lib/rpm/__*
rpm --rebuilddb
  • Thank you for your answer,but it did not work ,and I tried 3 times,the __db.00{1..4} was created after rpm --rebuilddb, the time of this files was lastest,Or should I back up something before rebuilddb?I feel confused.
    – Hongwei Lu
    Commented May 9, 2019 at 6:42

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .