Troubleshooting RPM Database issue

In this article, we are going to see how to fix the RPM Database issue in Linux system.

First, I’m trying to install the telnet package and got an error.

[root@server ~]# yum install telnet -y
..[Output Omitted]
Rpmdb checksum is invalid: dCDPT(pkg checksums): ncurses-base.noarch 0:5.9-14.20130511.el7_4 - u

Verify the integrity of the RPM database:

[root@server ~]# cd /var/lib/rpm/
[root@server rpm]# ll
total 76536
-rw-r--r--. 1 root root 1626112 May 1 10:30 Basenames
-rw-r--r--. 1 root root 8192 May 1 10:30 Conflictname
-rw-r--r--. 1 root root 270336 May 1 10:30 __db.001
-rw-r--r--. 1 root root 81920 May 1 10:30 __db.002
-rw-r--r--. 1 root root 1318912 May 1 10:30 __db.003
-rw-r--r--. 1 root root 581632 May 1 10:30 Dirnames
-rw-r--r--. 1 root root 8192 May 1 10:30 Group
-rw-r--r--. 1 root root 12288 May 1 10:30 Installtid
-rw-r--r--. 1 root root 24576 May 1 10:30 Name
-rw-r--r--. 1 root root 16384 May 1 10:30 Obsoletename
-rw-r--r--. 1 root root 72556544 May 1 10:30 Packages
-rw-r--r--. 1 root root 1785856 May 1 10:30 Providename
-rw-r--r--. 1 root root 147456 May 1 10:30 Requirename
-rw-r--r--. 1 root root 40960 May 1 10:30 Sha1header
-rw-r--r--. 1 root root 24576 May 1 10:30 Sigmd5
-rw-r--r--. 1 root root 8192 May 1 07:27 Triggername

[root@server rpm]# /usr/lib/rpm/rpmdb_verify Packages
rpmdb_verify: BDB1121 Page 1: item 152 hashes incorrectly
rpmdb_verify: BDB1116 Page 1: hash page referenced twice
rpmdb_verify: BDB1121 Page 17712: item 154 hashes incorrectly
rpmdb_verify: BDB1121 Page 17712: item 156 hashes incorrectly
rpmdb_verify: Packages: BDB0090 DB_VERIFY_BAD: Database verification failed
BDB5105 Verification of Packages failed.
[root@server rpm]#

Move Packages to Packages.bad and create a new RPM database from Packages.bad:

[root@server rpm]# mv Packages Packages.bad
[root@server rpm]# /usr/lib/rpm/rpmdb_dump Packages.bad | /usr/lib/rpm/rpmdb_load Packages
rpmdb_load: BDB1540 configured environment flags incompatible with existing environment
[root@server rpm]#
[root@server rpm]# /usr/lib/rpm/rpmdb_verify Packages
BDB5105 Verification of Packages succeeded.
[root@server rpm]#

Query installed packages for errors:

[root@server rpm]# rpm -qa > /dev/null

Rebuild the RPM database:

[root@server rpm]# rpm -vv --rebuilddb


Leave a Comment