Install MariaDB, the best RDBMS instead of MySQL

Install the best RDMBS, MariaDB

For years I have used MySQL as my default relational database management system or RDBMS. Since 2013 I have however discovered MariaDB. MariaDB is a database server that offers drop-in replacement functionality for MySQL. It is built by some of the original authors of MySQL (after a debacle with Oracle), with assistance from the broader community of free and open source software developers. In addition to the core functionality of MySQL (which we all love), MariaDB offers a rich set of feature enhancements including alternate storage engines, server optimizations, and patches. In thuis guide I will explain how to install the latest version of MariaDB and how to keep it up to date and secure it. This is the third st p in getting a LEMP stack — Linux, NGINX (pronounced Engine X), MySQL, PHP

→ A Linux (Ubuntu) server that has gone through the initial setup.
→ Have the open source NGINX web server installed (or another web server).
→ Know how to connect to your server via SSH (Terminal, Putty,…) or via a client that supports SFTP.
→ Know how to edit and save a file using SSH.
→ Don’t have a RDBMS installed.
Getting everything ready

In the same way we added the NGINX repository, we need to add the MariaDB repository. In order to do this we first of all need to add python-software-properties. In order to do this use the following command (you can skip this step if you have already did this when installing NGINX).

sudo apt-get install python-software-properties

With that out of the way, we can add the correct key so that we can add MariaDB.

Add the correct repository

It is important that you choose the correct repository as this is different for each operating system. You can find the correct one with the repository configuration tool on the MariaDB website:

In my case I choose Ubuntu > 12.04 LTS “precise” > 10.0 > a suitable mirror. This returned the following for me (this might be different for you depending on the versions and mirror you have chosen).

sudo add-apt-repository 'deb precise main'

As you can see, the configuration tool also outputs the previous commands we have already discussed, so you can skip that.

Installing MariaDB

After adding the repo (or any repo) you should always update the repositories.

sudo apt-get update

Now we are ready to install MariaDB.

apt-get install mariadb-server mariadb-client

While installing MariaDB using above command, the installer will prompt for MariaDB root account password twice. Choose a secure password.

Finishing up

To make sure that MariaDB is started properly, you can run this command.

service mysql start

The following steps are optional, but I alway like to run them. First of all run the MySQL install database command and follow the steps presented to you.

sudo mysql_install_db

Then reboot your server.


Now, after the reboot, to make sure everything has started properly when you rebooted and to check if MariaDB is installed correctly, check the status.

service mysql status

Finally, when you are sure that everything is perfectly installed, try to login to your MySQL server (user = root and you will be prompted for the password).

mysql -u root -p

Congratulations, you now have the best RDBMS (as of now) installed on your server. Go ahead and enjoy the features, improved performance and stability. It is a complete drop-in replacement for MySQL so you can use it in phpMyAdmin, use it for WordPress, use the same command,…


  1. help me resolve 502 bad gateway

Leave a Comment.