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)

  1. Make sure no other rpm, yum or dnf process is running: ps aux | grep -E "rpm|yum|dnf".
  2. Back up the database: cp -a /var/lib/rpm /root/rpm-backup-$(date +%F)
  3. On CentOS 7 and similar older systems, remove the stale lock files: rm -f /var/lib/rpm/__db.*.
  4. Rebuild the database: rpm --rebuilddb.
  5. Test: dnf clean all && dnf repolist (or yum).

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.

Related services

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.

Was this answer helpful?

Still stuck? Open a ticket