Install MariaDB on CentOS 6.4

By | November 25, 2013


MariaDB is the community developed fork of Mysql and is a great alternative to it. Its free and open source and is developed by the original developers of mysql. MariaDB is much superior to mysql in terms of features. Check out the comparison between mariadb and mysql.

And the best thing is, that its a drop-in replacement for mysql, which means that just install mariadb in place of mysql and all you mysql based applications would run with it the same way. All commands and drivers work the same way. Existing php mysql applications would run the same way with the mysql extensions for php.

1. Add mariadb repository on CentOS

MariaDB is not available in the default repositories of CentOS, so we have to first add the repositories provided by MariaDB. MariaDB provides repositories for distros including ubuntu, centos, debian, fedora.

Visit the following site

It is the repository generator. Select your linux distro, version and architecture.
It would then give instructions for adding the repository.

5.5 or 10

MariDB comes in 2 series. First is the 5.5 and the other is the newer 10.0 series. The 10.0 series has new features not present in either mysql or previous versions of mariadb. Check out the features of mariadb 10.
If you do not need those modern features of version 10.0 then you might want to go with the 5.5 series. If you are permanently migrating away from mysql, then you can first import your database to mariadb 5.5 and then move on to version 10, just to avoid any compatibility issues. In case of any problems just drop in the irc channel #mariadb to get some free help.

We are doing it on CentOS 6.4 x64 so I would select the options accordingly. gives me the following repository details for my distro.

Here is your custom MariaDB YUM repository entry for CentOS. Copy and paste it into a file under /etc/yum.repos.d/ (we suggest naming the file MariaDB.repo or something similar). See "Installing MariaDB with yum" for detailed information.
# MariaDB 5.5 CentOS repository list - created 2013-11-09 11:31 UTC
name = MariaDB
baseurl =

So we create a file called /etc/yum.repos.d/mariadb.repo and fill it with the text given above.

2. Install mariadb with yum

Now do a yum search to see that packages in repository, just to make sure that we configured the repository properly and to get the exact package name to use with the install command later.

# yum search mariadb
Loaded plugins: fastestmirror
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * rpmforge:
 * updates:
mariadb                                                                                                                                 | 1.9 kB     00:00     
Not using downloaded repomd.xml because it is older than what we have:
  Current   : Wed Nov  6 07:36:52 2013
  Downloaded: Mon Sep 30 00:49:11 2013
==================================================================== N/S Matched: mariadb =====================================================================
MariaDB-cassandra-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-client.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-common.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-compat.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-connect-engine.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-devel.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-server.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-shared.x86_64 : MariaDB: a very fast and robust SQL database server
MariaDB-test.x86_64 : MariaDB: a very fast and robust SQL database server

  Name and summary matches only, use "search all" for everything.

As we can see, the necessary MariaDB packages are right there ready to be installed. Now do a yum install to finish the task.

# yum install MariaDB-server MariaDB-client

That should complete the mariadb installation.

3. Start mysql server and connect to it

First start mysql server using the service command. Then connect to it using the mysql command.

# service mysql start
Starting MySQL.. SUCCESS! 

# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 1
Server version: 5.5.33a-MariaDB MariaDB Server

Copyright (c) 2000, 2013, Oracle, Monty Program Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

As can be seen above, the mysql command allowed us to connect as root without asking for a password. This is how mariadb is configured by default and is not secure for production environment. To fix this we need to se a root password and do other security improvements, as shown in the next section.

4. Run the mysql_secure_installation script

By default mariadb installs without a root password and many other insecure settings. To fix all these, run the mysql_secure_installation script and secure the installation. It does the following things

1. Set root password
2. Remove anonymous user
3. Disallow remote root login
4. Remove test database

# mysql_secure_installation 
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found


In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

Set root password? [Y/n] y
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] y
 ... Success!

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y
 ... Success!

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!
[root@analytics public_html]#

Done. Now we have done some basic security improvement for MariaDB.

5. Enable MariaDB to start at boot

Use the chkconfig command to enable mariadb to start at boot.

# chkconfig mysql on

Thats it. MariaDB is now installed and ready for use. You might want to reboot the system to ensure that it is working as expected. Check the status with the service command

# service mysql status
 SUCCESS! MySQL running (1451)
About Silver Moon

A Tech Enthusiast, Blogger, Linux Fan and a Software Developer. Writes about Computer hardware, Linux and Open Source software and coding in Python, Php and Javascript. He can be reached at [email protected].


Install MariaDB on CentOS 6.4
  1. ZombieProcesses

    Good article. One note: Where it says “mysql” or “mysqld” in the start and enable commands, you may need to use mariadb instead.

Leave a Reply

Your email address will not be published. Required fields are marked *