Rocky Update Error: RPM: error: cannot open Packages index using bdb_ro – Operation not permittedRocky Update Error:

It’s been a while but trying to get back in the habit of posting again. If you run into this while doing an update there is an easy fix. This is in later releases so you may or may not run across it:

Problem

# dnf update -y
...
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
RPM: warning: Found bdb_ro Packages database while attempting sqlite backend: using bdb_ro backend.
RPM: error: cannot open Packages index using bdb_ro - Operation not permitted (1)
RPM: error: cannot open Packages database in /var/lib/rpm
The downloaded packages were saved in cache until the next successful transaction.
You can remove cached packages by executing 'dnf clean packages'.
Error: Could not run transaction.
...

Fix

# restorecon -Rv /var/lib/rpm
# rpmdb --rebuilddb

# dnf update -y
...
Dependencies resolved.
========================================================================================================================= Package Architecture Version Repository Size
=========================================================================================================================Installing:
kernel x86_64 5.14.0-362.24.1.el9_3.0.1 baseos 4.6 M
kernel-core x86_64 5.14.0-362.24.1.el9_3.0.1 baseos 19 M
kernel-modules x86_64 5.14.0-362.24.1.el9_3.0.1 baseos 37 M
Upgrading:
expat x86_64 2.5.0-1.el9_3.1 baseos 115 k
gnutls x86_64 3.7.6-23.el9_3.4 baseos 1.0 M
grub2-common noarch 1:2.06-70.el9_3.2.rocky.0.5 baseos 903 k
grub2-pc x86_64
...
Installed products updated.

Upgraded:
expat-2.5.0-1.el9_3.1.x86_64 gnutls-3.7.6-23.el9_3.4.x86_64
grub2-common-1:2.06-70.el9_3.2.rocky.0.5.noarch grub2-pc-1:2.06-70.el9_3.2.rocky.0.5.x86_64
grub2-pc-modules-1:2.06-70.el9_3.2.rocky.0.5.noarch grub2-tools-1:2.06-70.el9_3.2.rocky.0.5.x86_64
grub2-tools-efi-1:2.06-70.el9_3.2.rocky.0.5.x86_64 grub2-tools-extra-1:2.06-70.el9_3.2.rocky.0.5.x86_64
grub2-tools-minimal-1:2.06-70.el9_3.2.rocky.0.5.x86_64 kernel-tools-5.14.0-362.24.1.el9_3.0.1.x86_64
kernel-tools-libs-5.14.0-362.24.1.el9_3.0.1.x86_64 less-590-3.el9_3.x86_64
python3-perf-5.14.0-362.24.1.el9_3.0.1.x86_64 python3-unbound-1.16.2-3.el9_3.5.x86_64
rocky-gpg-keys-9.3-1.3.el9.noarch rocky-release-9.3-1.3.el9.noarch
rocky-repos-9.3-1.3.el9.noarch unbound-libs-1.16.2-3.el9_3.5.x86_64
Installed:
kernel-5.14.0-362.24.1.el9_3.0.1.x86_64 kernel-core-5.14.0-362.24.1.el9_3.0.1.x86_64
kernel-modules-5.14.0-362.24.1.el9_3.0.1.x86_64 kernel-modules-core-5.14.0-362.24.1.el9_3.0.1.x86_64
Removed:
kernel-4.18.0-80.el8.x86_64 kernel-core-4.18.0-80.el8.x86_64 kernel-modules-4.18.0-80.el8.x86_64

Complete!
...