LAMP on CentOS – MariaDB

A LAMP (Linux, Apache, MySQL, PHP) stack is a common web stack used for hosting web content. Let’s install MariaDB (MySQL) on a RHEL/CentOS 7 server.

MariaDB is a free and open source fork of well known MySQL database management server software, developed by the brains behind MySQL, it’s envisioned to remain free/open source.

In this tutorial, we will show you how to install MariaDB 10.1 stable version in the most widely used versions of RHEL/CentOS and Fedora distributions.

For your information, Red Hat Enterprise LinuxRHEL /CentOS 7.0 switched from supporting MySQL to MariaDB as the default database management system.

Note that in this tutorial, we’ll assume your working on the server as root, otherwise, use the sudo command to run all the commands.

1: Add MariaDB Yum Repository

1. Start by adding the MariaDB YUM repository file MariaDB.repo for RHEL/CentOS and Fedora systems.

# vi /etc/yum.repos.d/MariaDB.repo

Now add the following lines to your respective Linux distribution version as shown.

On CentOS 7
[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

On RHEL 7

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.1/rhel7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

2: Install MariaDB

Once MariaDB repository has been added, you can easily install it with just one single command.

# yum install MariaDB-server MariaDB-client -y

3. Manage MariaDB

As soon as the installation of MariaDB packages completes, start the database server daemon for the time being, and also enable it to start automatically at the next boot like so:

# systemctl start mariadb
# systemctl enable mariadb
# systemctl status mariadb

4. Secure MariaDB

Now its time to secure your MariaDB by setting root password, disabling remote root login, removing the test database as well as anonymous users and finally reload privileges as shown in the screen shot below:

# mysql_secure_installation

5. check certain MariaDB features

After securing the database server, you may want to check certain MariaDB features such as: installed version, default program argument list, and also login to the MariaDB command shell as follows:

# mysql -V
# mysqld --print-defaults
# mysql -u root -p


Step by step, installing Apache, MariaDB, PHP, and phpMyAdmin

  1. Part 1: Install Apache on RHEL/CentOS 7
  2. Part 2: Install MariaDB on RHEL/CentOS 7
  3. Part 3: Install PHP on RHEL/CentOS 7
  4. Part 4: Install phpMyAdmin on RHEL/CentOS 7

Thats all for now!

You may also like: