How to Install MariaDB on CentOS 8

Install MariaDB on CentOS 8

In this article, we will have explained the necessary steps to install and configure MariaDB on CentOS 8. Before continuing with this tutorial, make sure you are logged in as a user with sudo privileges. All the commands in this tutorial should be run as a non-root user.

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.

Install MariaDB on CentOS

Step 1. The first command will update the package lists to ensure you get the latest version and dependencies.

sudo yum update

Step 2. Install MariaDB on CentOS 8.

The default CentOS 8 AppStream repo contains MariadB 10.3. To install MariaDB 10.4, you need to install its YUM repository:

cat << EOF > /etc/yum.repos.d/mariadb.repo
[mariadb]
name = MariaDB-10.4
baseurl=http://yum.mariadb.org/10.4/centos8-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1
EOF

Next, install MariaDB YUM repository signing key:

rpm --import https://yum.mariadb.org/RPM-GPG-KEY-MariaDB

Next, Install MariaDB 10.4 using yum package manager:

sudo yum --disablerepo=AppStream install MariaDB-server MariaDB-client

After installing MariaDB in your system start it’s service using the following command:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 3. Secure the installation of MariaDB.

After installation, we have to improve MariaDB security by typing following:

sudo mysql_secure_installation

Then enter yes/y to the following security questions:

Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
    Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
    Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
    Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y

Install MariaDB on CentOS 8

As a test, you can log into the MySQL server and run the version command:

sudo mysqladmin -p -u root version

Congratulation, you have learned how to install and configure MariaDB on CentOS 8. If you have any question, please leave a comment below.