MariaDB server installation CentOS 8

Published: October 27, 2020 (Updated: Oct 27, 2020)

Enjoying this content? Subscribe to the Channel!

Lightning Fast: Install MariaDB Server on CentOS 8 (The Easy Way!)

Welcome to Darren’s Tech Tutorials!

Hey everyone, and welcome back to the channel! If you’re building applications, managing data, or just diving into the world of database administration, you know how crucial a reliable, high-performance database is. Today, we’re focusing on one of the best open-source options out there: MariaDB.

MariaDB is a powerful, community-developed fork of the popular MySQL database system, known for its speed, stability, and extensive feature set.

In this comprehensive guide, we’re going to walk through the exact steps required to install the MariaDB Server on a CentOS 8 system. While we are targeting CentOS 8 specifically, this process is generally identical for other Red Hat-based Linux distributions, including RHEL and Fedora. Let’s get started!


Why Choose MariaDB?

Before we jump into the commands, it’s worth noting why MariaDB is a fantastic choice for your server stack:

  • Open Source & Free: Enjoy powerful database management without licensing costs.
  • High Compatibility: As a fork of MySQL, it maintains high compatibility, making migration simple.
  • Performance: MariaDB includes several storage engine improvements and optimizations that often result in better performance metrics compared to legacy MySQL setups.

Prerequisites

To follow this tutorial, you will need:

  1. A fresh installation of CentOS 8 (or a similar Red Hat-based system).
  2. Root or Sudo privileges on the system to execute administrative commands.
  3. An active internet connection to download the necessary packages.

Step 1: Update Your System Packages

It’s always best practice to ensure your system is running the latest software before installing new applications. This helps resolve potential dependency issues and ensures you are working with the most secure configuration available.

Use the yum package manager to update your system:

sudo yum update -y

Step 2: Install the MariaDB Server and Client

CentOS 8 includes MariaDB packages in its default AppStream repository, making the installation incredibly straightforward using yum. We need to install two main components: the client (to connect and interact with the database) and the server (the core database engine).

Run the following commands to install the required packages:

Install the MariaDB Client:

sudo yum install mariadb

Install the MariaDB Server:

sudo yum install mariadb-server

When prompted, confirm the installation and dependency resolution by pressing y.

Step 3: Enable and Start the MariaDB Service

Once the installation is complete, the MariaDB service needs to be enabled to start automatically upon system boot, and then started for immediate use. We use the systemctl utility for managing system services.

3a. Start the MariaDB Service

Start the database service now:

sudo systemctl start mariadb

3b. Enable Auto-Start

Enable the service to start automatically after a reboot:

sudo systemctl enable mariadb

3c. Verify the Service Status

Finally, let’s verify that the service is running correctly. You should see an “active (running)” status in the output:

sudo systemctl status mariadb

Step 4: Secure Your MariaDB Installation (Crucial Step!)

By default, the MariaDB installation is insecure. The root user does not have a password, and test databases are accessible. To lock down your installation and secure your data, you must run the built-in security script: mysql_secure_installation.

Run the following command:

sudo mysql_secure_installation

You will be prompted to answer a series of questions:

  1. Enter current password for root (enter for none): Since this is a fresh install, just hit Enter.
  2. Set root password? [Y/n]: Type Y and set a strong, secure password for the database root user. Do not confuse this with your system root password.
  3. Remove anonymous users? [Y/n]: Type Y. This removes temporary users that can access the database without authentication.
  4. Disallow root login remotely? [Y/n]: Type Y. This is a critical security measure that prevents remote attackers from using the root account.
  5. Remove test database and access to it? [Y/n]: Type Y.
  6. Reload privilege tables now? [Y/n]: Type Y.

Once complete, your MariaDB server is installed, running, and properly secured!

Conclusion and Next Steps

Congratulations! You have successfully installed and secured the powerful MariaDB Server on your CentOS 8 system.

From here, you can start creating databases, setting up user accounts, and connecting your applications. If you need a more in-depth guide on creating users or optimizing MariaDB for production, let me know in the comments!

We’ve covered the installation process step-by-step, making it incredibly easy even for those new to Linux administration. Now that you’re running one of the fastest open-source databases around, the sky’s the limit for your projects!

If this tutorial helped you get your server running, please take a moment to Like this post and Subscribe to Darren’s Tech Tutorials for more clear, actionable guides just like this one. Happy coding!