How to install MariaDB on CentOS 9 Stream

Estimated reading: 3 minutes 372 views


MariaDB is an open-source relational database management system (DBMS) that is a compatible drop-in replacement for the widely used MySQL database technology. MariaDB is based on SQL and supports ACID-style data processing with guaranteed atomicity, consistency, isolation, and durability for transactions.

In this article, we will show you how to install MariaDB on a CentOS 9 stream server/VPS instance.


  • An active KVM VPS
  • root user

Install MariaDB 

To install the MariaDB server, you need to create a MariaDB repository configuration file mariadb.repo manually with this path ‘/etc/yum.repos.d/’

To create a MariaDB repository file, you can use the following command,

vi /etc/yum.repos.d/mariadb.repo

The above command will create a new repository file, Once it is created, you need to add the following configurations in that file,

# MariaDB 10.11 RedHatEnterpriseLinux repository list 
name = MariaDB
# is a dynamic mirror if your preferred mirror goes offline. See for details.
# baseurl =$releasever/$basearch
baseurl =$releasever/$basearch
# gpgkey =
gpgkey =
gpgcheck = 1

Save and exit file.

Installing MariaDB Server

dnf install MariaDB-server MariaDB-client

You will be presented with a series of prompts. Here’s what you’ll be asked and how to respond:

Install  78 Packages

Total download size: 39 M
Installed size: 265 M
Is this ok [y/N]: y

Total                                                                                   6.5 MB/s |  39 MB     00:06
MariaDB                                                                                  17 kB/s |  15 kB     00:00
Importing GPG key 0x1BB943DB:
 Userid     : "MariaDB Package Signing Key <[email protected]>"
 Fingerprint: 1993 69E5 404B D5FC 7D2F E43B CBCB 082A 1BB9 43DB
 From       :
Is this ok [y/N]: y
Key imported successfully
Importing GPG key 0xC74CD1D8:
 Userid     : "MariaDB Signing Key <[email protected]>"
 Fingerprint: 177F 4010 FE56 CA33 3630 0305 F165 6F24 C74C D1D8
 From       :
Is this ok [y/N]: y

Once the installation is complete, you can verify the version of the MariaDB server by using the following command:

mysql -V


Screenshot of GIT post-compilation on CentOS Stream el9 or el8.

Now, enable MariaDB (to start automatically upon system boot), start the MariaDB and verify the status using the commands below

systemctl enable mariadb

systemctl start mariadb

systemctl status mariadb


Screenshot of GIT post-compilation on CentOS Stream el9 or el8.

Secure your MariaDB server

You can secure your MariaDB installation by following these steps

Start the MariaDB shell:


Change the root user’s password:

ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';

Replace ‘your_new_password’ with the password you want to set for the root user.

Remove anonymous users:

DELETE FROM mysql.user WHERE User='';

Disallow remote root login. This ensures that the root user can only log in from the localhost:

DELETE FROM mysql.user WHERE User='root' AND Host NOT IN ('localhost', '', '::1');

Remove the test database:


Reload the privileges to apply the changes:


Exit the MariaDB shell:


Access MariaDB server

To login to the MariaDB server, enter the following command with the password that was set previously,

mysql -u root -p


Screenshot of GIT post-compilation on CentOS Stream el9 or el8.

Creating a new database and new user with a password

Let’s create a new database with a custom user and password.

First, log in as root user, then type the following commands:

mysql -u root -p


CREATE user green;

GRANT ALL ON greencloud.* TO green@localhost IDENTIFIED BY 'password';


That’s it! Enjoy GreenCloudVPS services!

Leave a Comment