使用yum时出现Error: rpmdb open failed解决方案

 运维   大苹果   2023-12-02 13:51   86
  centos yum

一、问题描述

  使用yum安装软件时出现Error: rpmdb open failed,报错信息显示rpm数据库被损坏。
image.png
二、解决方案

  • 重建rpm数据库。
[root@localhost yum.repos.d]# cd /var/lib/rpm

[root@localhost rpm]# ls
Basenames __db.001 __db.003 Group Name Packages Requirename Sigmd5
Conflictname __db.002 Dirnames Installtid Obsoletename Providename Sha1header Triggername

[root@localhost rpm]# rm __db.* -rf
[root@localhost rpm]# ls
Basenames Dirnames Installtid Obsoletename Providename Sha1header Triggername
Conflictname Group Name Packages Requirename Sigmd5

[root@localhost rpm]# rpm --rebuilddb
[root@localhost rpm]# yum clean all
已加载插件:langpacks, product-id, search-disabled-repos, subscription-manager
This system is not registered with an entitlement server. You can use subscription-manager to register.
正在清理软件源: local nginx
Cleaning up everything
Maybe you want: rm -rf /var/cache/yum, to also free up space taken by orphaned data from disabled or removed repos

三、结果验证

image.png