How to Solve Yum Error: db5 error(30973)

Problem error: failed to open rpmdb. db5 error(30973)

error: rpmdb: BDB0113 Thread/process 8442/140713489532992 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 -  (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.main:

Error: rpmdb open failed
[root@VM-0-6-centos ~]# yum-config-manager --add-repo http://mirrors.aliyun.com/docker-ce/linux/centos/docker-ce.repo
error: rpmdb: BDB0113 Thread/process 8442/140713489532992 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 -  (-30973)
error: cannot open Packages database in /var/lib/rpm
CRITICAL:yum.cli:Yum Error: Error: rpmdb open failed

The reason why rpm is damaged: the database needs to be rebuilt.

Solution: clear the original link through the command and re-establish it.

[root@localhost ~]# rm -rf /var/lib/rpm/_db*  #Delete the original
[root@localhost ~]# rpm --rebuilddb # New
[root@localhost ~]# yum clean all # Clear all yum caches

It can be used normally at present

Read More: