The cart is empty

CentOS 7, one of the most popular Linux distributions for web servers, replaces the traditional MySQL with the MariaDB database system by default. MariaDB is a fork of MySQL, created out of concerns regarding the acquisition of MySQL by Oracle. It offers high compatibility with MySQL, meaning that scripts and applications developed for MySQL should work similarly with MariaDB. In this article, you'll learn how to install MariaDB on CentOS 7.

Preparation

Before installing MariaDB, it's good to ensure that your system is fully up-to-date. Open a terminal and run the following command to update your system:

sudo yum update

Installing MariaDB

Once the system update is complete, you can proceed directly to installing MariaDB. CentOS 7 has MariaDB available in its default repositories, making the installation process straightforward. To install MariaDB, use the following command:

sudo yum install mariadb-server

Starting MariaDB

After the installation is complete, you need to start MariaDB. Use the systemctl service manager to start and enable MariaDB on your system:

sudo systemctl start mariadb
sudo systemctl enable mariadb

The enable command ensures that MariaDB will start automatically upon system boot.

Securing MariaDB

After installation, it's important to perform basic security measures on the database server. MariaDB includes a security script that helps you set a password for the root user, remove anonymous users, disallow root login remotely, and remove test databases. Run the script with the following command:

sudo mysql_secure_installation

During the process, you'll be prompted to set a password for the root user and perform other recommended security measures.

Testing the Installation

To verify that MariaDB is running correctly, you can attempt to log in to MariaDB using the command-line interface:

mysql -u root -p

You'll be prompted to enter the password for the root user, which you set during the installation security process. Upon entering the password, you should be logged in to MariaDB.

 

You now have MariaDB successfully installed and secured on your CentOS 7 server. This step lays the foundation for running web applications that require a database backend. With MariaDB, you have a powerful and open-source database system that is fully compatible with MySQL, allowing for easy migration and compatibility with existing applications.