Updated: 28 September 2026 · Applies to: AlmaLinux 9, Rocky Linux 9, Ubuntu 24.04 and Debian 12
Errors such as "cannot open Packages database in /var/lib/rpm" or "rpmdb: Thread died in Berkeley DB library" mean the RPM package database is damaged or locked, so yum/dnf cannot run.
Fix (root)
- Make sure no other
rpm,yumordnfprocess is running:ps aux | grep -E "rpm|yum|dnf". - Back up the database:
cp -a /var/lib/rpm /root/rpm-backup-$(date +%F) - On CentOS 7 and similar older systems, remove the stale lock files:
rm -f /var/lib/rpm/__db.*. - Rebuild the database:
rpm --rebuilddb. - Test:
dnf clean all && dnf repolist(oryum).
Note: On AlmaLinux, Rocky Linux and RHEL 9, the RPM database is a single SQLite file, and rpm --rebuilddb alone is usually enough. On cPanel servers, WHM › Software › Rebuild RPM Database does the same.
Ucartz services for this topic
- KVM VPS hosting: NVMe SSD and full root access, with Free Basic Managed Support.
- Unmanaged dedicated servers: full root access and free IPMI KVM, with Free Basic Managed Support.
- Linux server management: hardening, patching, monitoring and automation for Ubuntu, Debian, RHEL and AlmaLinux.
