Yum RPMDB failed

If you are getting a similar error from yum similar to the one below, it looks like yum is broken in your system.

error: rpmdb: BDB0113 Thread/process 2196/139984719730496 failed: BDB1507 Thread died in Berkeley DB library
error: db5 error(-30973) from dbenv->failchk: BDB0087 DB_RUNRECOVERY: Fatal error, run database recovery
error: cannot open Packages index using db5 - (-30973)
error: cannot open Packages database in /var/lib/rpm
Error: rpmdb open failed

Here’s the fix.

mv /var/lib/rpm/__db* /tmp
yum clean all

Run your yum commands. The errors should be gone.

Check DB Connection on AWS

When setting up your cloud infrastructure, you can check if your instances have access to the database by performing this command.

$ nc -zv 3306
$ nc -zv domain.com 3306
$ nc -zv endpoint.amazonaws.com 3306

If connection has succeeded, you’ll get a message like this in Linux and MacOS …

Connection to endpoint.amazonaws.com 3306 port [tcp/mysql] succeeded!

On Windows, you can use Telnet to test your DB connection.

C:\>telnet endpoint.amazonaws.com 3306

If connection has succeeded, the result is “no message.” If there’s a problem, you’ll get this ….

Connecting To endpoint.amazonaws.com...Could not open 
connection to the host, on port 3306: Connect failed

Install MariaDB on Ubuntu

MariaDB is a drop-in replacement for MySQL database. On most cases, you can just uninstall MySQL and install MariaDB and you are good to go. To keep up the two databases compatible, the MariaDB team are doing monthly merges with the MySQL code base making sure new features and fixes are kept up.

Uninstall MySQL

sudo apt-get purge mysql*
sudo apt-get autoremove

Install MariaDB

sudo apt-get install mariadb-server mariadb-client -y

Verify if MariaDB is running

sudo service mysql status