How to Install MariaDB on Centos 6

By | March 26, 2018
How to Install MariaDB on Centos 6

How to Install MariaDB on Centos 6

How to Install MariaDB on Centos 6

I decided to write this tutorial as many of the others on various sites seem to miss key parts of what should be a straightforward install. MariaDB is the latest version of mysql and uses as far as i can see the same code and commands as mysql.

I have just done this install on a fresh install of Centos 6 so here are the instructions –

1) First you need to add the repository. Edit a file called /etc/yum.repos.d/MariaDB.repo and add the following info –

name = MariaDB
baseurl =

2) Additional bits that are needed –

yum -y install jemalloc nmap

3) Now to install the MariaDB server –

yum -y install MariaDB-server MariaDB-client

4) All other articles then say you should start the DB, but when I did that I hit some errors like these –

[root ~]# service mysql start
Starting MariaDB.180326 06:04:54 mysqld_safe Logging to '/var/lib/mysql/com.err'.
180326 06:04:54 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
[root ~]#

So after looking at the error logs firstly it appears that the install does not create the data directory so you should do that –

mkdir /var/lib/mysql
chown mysql:mysql /var/lib/mysql

Then you also need to tell MariaDB to use that data directory so edit /etc/my.cnf.d/server.cnf and add the datadir line –

# this is only for the mysqld standalone daemon

5) Now you have a data directory and a config file to point to it, you can now initialise your database –

Check out -  Bash remove duplicate lines without sorting

mysql_install_db --user=mysql

If you are familiar with an old mysql install you will know that you can then run the secure install to remove demo dbs and set the root password by doing this –


6) You can then check a restart of the database works ok –

service mysql restart

And set mysql to auto start after a server reboot –

chkconfig mysql on

That should do it mariadb is all ready to go !

Leave a Reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.