Install MariaDB on CentOS 7 with these Simple Steps

December 16, 2016 / Database

An open-source database management system, MariaDB commonly installed as part of the popular LEMP (Linux, Nginx, MySQL/MariaDB, PHP/Python/Perl) stack. The data managed by MariaDB by using a relational database and SQL (Structured Query Language). It acts as a fork of MySQL that managed by the original MySQL developers. Since it’s designed as a replacement for MySQL. It uses commands that reference MySQL and is the default package on CentOS 7.

This tutorial explains the installation of the latest version of MariaDB on a CentOS 7 server.


To work as per this tutorial you will need –

A CentOS 7 with a non-root with sudo privileges.

  1. Installation of MariaDB
    In this tutorial yum will used to install the MariaDB package. Pressing y when prompted to confirm that we are ready to proceed.
    sudo yum install mariadb-server
    After the installation is complete, start the daemon with the command as below –
    sudo systemctl start mariadb
    As systemctl doesn’t display the outcome of all service management commands. The following command needs to used to check whether the previous command was successful –
    sudo systemctl status mariadb
    If the MariaDB started successfully. The output should contain “Active: active (running)” and the final line needs to look like this –
    Dec 16 19:06:20 centos-512mb-sfo2-01 systemd[1]: Started MariaDB database server.
    Now, let’s check if MariaDB starts at boot using the systemctl enable command that will create the essential symlinks.
    sudo systemctl enable mariadb
    Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/mariadb.service.
  2. Securing the MariaDB Server
    There’s a security script to change some of the less secure default options for things like remote root logins and sample users. Use the command below to run the security script –
    sudo mysql_secure_installation
    You get detailed information for every step with this script. Firstly, you prompted for the root password which hasn’t been set so press ENTER after its recommendation. Next, prompted to set the root password which you will need to insert.

    Then accept all security suggestions by pressing Y and pressing ENTER for the remaining prompts. That will remove anonymous users. Disallow remote root login, remove the test database and reload the privilege tables.

  3. Installation Testing
    Installation can be verified and one can get information about it by connecting with the mysqladmin tool, a client that lets you run administrative commands. Use the command below to connect to MariaDB as root (-uroot), prompt for a password (-p), and return the version –
    mysqladmin -u root -p version
    The output will be similar to this –
mysqladmin  Ver 9.0 Distrib 5.5.50-MariaDB, for Linux on x86_64

Copyright (c) 2000, 2016, Oracle, MariaDB Corporation Ab and others.

Server version          5.5.50-MariaDB
Protocol version        10
Connection              Localhost via UNIX socket
UNIX socket             /var/lib/mysql/mysql.sock
Uptime:                 4 min 4 sec

Threads: 1  Questions: 42  Slow queries: 0  Opens: 1  Flush tables: 2  Open tables: 27  Queries per second avg: 0.172

This proves that the installation is successful.