4.5.3. Creating a new RPM database
If all else fails, use the --initdb option to tell the rpm command to create a new empty RPM database. In almost all cases, you do not want to create a new RPM database, since this database will be empty. It will not have any knowledge about the packages you have already installed on your system. That could lead to a lot of problems, since you have the files installed, but the RPM system just doesn’t know about them.
The basic syntax follows.
rpm --initdb
Note
This command should not damage an existing database.
If the RPM system cannot be rebuilt, you may have to reinstall the operating system to recreate a clean system. In general, if things are this far gone, reinstalling may be your best answer instead of wiping the RPM database and creating an empty database.
You can also use the --dbpath option to tell the rpm command to create an RPM database in a different directory.
For example:
mkdir /tmp/rpm
rpm --initdb --dbpath /tmp/rpm
These commands create a temporary directory and an RPM database in the /tmp/rpm directory.
After running this command, you can examine the files created.
# ls -l /tmp/rpm
total 288
-rw-r--r-- 1 root root 8192 Oct 10 20:29 __db.001
-rw-r--r-- 1 root root 1310720 Oct 10 20:29 __db.002
-rw-r--r-- 1 root root 360448 Oct 10 20:29 __db.003
-rw-r--r-- 1 root root 12288 Oct 10 20:29 Packages
This shows an empty RPM database.