How to install MariaDB on CentOS 9 Stream?

MariaDB is a fork of MySQL 100% compatible and has managed to position itself as a very solid alternative to it. That is why many developers choose it for their projects. Today, you will learn how to install MariaDB on CentOS 9 Stream.

Introduction

MariaDB is a relational database manager that is a derivative of MySQL. Being a fork, it is 100% compatible with MySQL but has incorporated new and excellent features.

Although they are compatible, the truth is that there are many differences between the two that we have addressed. Despite everything, it can already be affirmed that MariaDB is a very solid alternative and used by many projects at a general level.

As expected, MariaDB is open source and is fully available for many Linux distributions, and CentOS 9 Stream is no exception.

Install MariaDB on CentOS 9 Stream

MariaDB is present in the official CentOS 9 Stream repositories. This makes the installation easier to do.

So, connect to a session via SSH or open a terminal.

After you do that, update the whole system with the command:

sudo dnf update

Then, you can request information about the mariadb-server package that is responsible for providing MariaDB

sudo dnf info mariadb-server

You will get an output screen like this:

MariaDB package info on CentOS 9 Stream
MariaDB package info on CentOS 9 Stream

Now, install MariaDB with the following command:

sudo dnf install mariadb-server

When the installation is finished, you will be able to check the installed version.

mariadb --version
mariadb  Ver 15.1 Distrib 10.5.16-MariaDB, for Linux (x86_64) using  EditLine wrapper

Although this is not the only way to know the version of MariaDB and there are several.

Manipulating the MariaDB service

On CentOS, by default, when MariaDB is installed, it does not start automatically. To do so, then you have to run.

sudo systemctl start mariadb

Normally, MariaDB is started by the system. If you want it to do so, run.

sudo systemctl enable mariadb

Then, check the status of the service

sudo systemctl status mariadb

You will get the following output

MariaDB service status
MariaDB service status

This indicates that MariaDB is running without problems.

If you want to stop the service at some point

sudo systemctl stop mariadb

Or restart it to apply the changes you have made.

sudo systemctl stop mariadb

Configuring MariaDB on CentOS 9 Stream

After you have MariaDB up and running, it’s time to do some basic configuration.

To achieve this, you will need to run the mysql_secure_installation script to get things started.

sudo mysql_secure_installation

You will be prompted for a root password that does not exist currently, so press Enter.

Now, you will be asked if you want to change it.

If you tell the script yes, then you will be able to set your password. Needless to say, it must be strong and secret.

Now you will be asked a few configuration questions.

Remove anonymous users [Y/n]
Disallow root login remotely [Y/n] 
Remove test database and access to it [Y/n
Reload privilege tables now [Y/n] 

To each of them, you will have to answer as you see fit.

When finished, MariaDB will be ready for you to use.

Logging into the MariaDB console

With MariaDB ready, you can log in to the console by running

sudo mysql -u root -p

After entering the root password, you will be ready to use it.

Uninstall MariaDB on CentOS 9 Stream

If you wish, you can uninstall MariaDB in the following way

sudo dnf remove mariadb

This way you will no longer have it on your system, and you will be able to save space. Note that this process should be done after backing up the databases to avoid any inconvenience.

Conclusion

If you read the whole post, now you know how to install MariaDB on CentOS 9 Stream. So now you can start dealing with it.

I hope you liked the post and help us to share it.

Leave a Comment

Your email address will not be published. Required fields are marked *

Scroll to Top