How to Install MariaDB on CentOS
On a fresh Linux installation, you may have MySQL already installed on your system. While that might be enough for most users, sometimes the newest version of the query language is necessary for some software to work. This tutorial will show you how to install MariaDB as a drop-in replacement for MySQL for all versions of CentOS, and all versions of MariaDB.
What is MariaDB?
When Oracle took over the development of MySQL in 2008, it switched to a slower release cycle, and the development became a lot more opaque. One of the lead developers of MySQL decided to fork the project, and MariaDB is the result. The idea was to continue the development of the database in a community-driven manner and to provide a “drop-in” replacement for MySQL.
What is a “Drop-in” Replacement?
It simply means that you don’t have to change any other configuration on systems that rely on MySQL. Once you install and activate MariaDB, all other programs that used to work with MySQL will now work seamlessly on MariaDB.
In other words, if you’re running WordPress, you don’t need to change any scripts or your wp-config.php file when you migrate to MariaDB.
Here’s how to install MariaDB on a CentOS VPS.
Step 1: Get the MariaDB and CentOS Version
The URL from which we get the MariaDB packages depends on the OS version, as well as the version of MariaDB we want to install. To get your OS version, type the following command:
This will tell you which version of CentOS you’re running. In this example, we’re going to use CentOS version 6.10. As of this writing, the stable version of MariaDB is sitting on 10.3, so that’s what we’re going to install right now.
Step 2: Get the Script for the MariaDB Repository
The official website makes it easy to configure the repository script. Visit the interactive tool and choose your OS, as well as the OS version and the MariaDB package that you want to install, based on what you decided in Step 1. Here’s a screenshot of our configuration:
Once you make these selections, it’ll display a snippet of text on the bottom of the page. Like this:
The important part is the “baseurl” parameter as shown above. This is what varies between various installations.
Step 3: Create the Repo File in CentOS
The next step is to create a file in the following directory:
We’re going to name it “MariaDB.repo” for easy reference later on. Use a text editor like nano or vi to paste the code you got in Step 2 into the file like this:
Save your changes, and you’re done with adding the repository file. Make sure to have yum recognize the changes by running this command:
sudo yum update
Step 4: Installing MariaDB
Now that the repo is configured, we can install MariaDB by typing in the following:
sudo yum install MariaDB-server MariaDB-client
Note that if you had a previous MariaDB repo, or accidentally used the wrong one, you would have gotten a message saying:
"No package MariaDB-server available"
Unfortunately, the configurations are saved, so before you run the “yum” command with a new repo, you must remember to flush it with the command:
yum clean metadata
But if everything goes well, you should now be able to install the MariaDB packages like this:
Note how it says “replacing mysql”. This means that the new database system will response to the “mysql” command from now on.
If this is the first time you’re installing MariaDB, you’ll also be asked to confirm the import of the GPG key as shown here:
After the installation is complete, you will have MariaDB on your system!
Step 5: Verifying the Installation
MariaDB is such a perfect replacement for
It will give you the version information, as well as the database system that’s driving it:
If you followed the tutorial step by step, then congratulations, you’ve replaced MySQL with MariaDB!
Of course, you don’t need to install MariaDB yourself if you have a CentOS VPS hosted with us, in which case our expert sysadmins will install MariaDB for you. They are available 24×7 and can help you with any questions or issues that you may have.
PS. If you enjoyed reading this blog post on how to install MariaDB on CentOS, feel free to share it on social networks using the share shortcuts, or simply leave a comment. Thanks.