Install MariaDB 10.3 on CentOS 7


This guide will quickly take you through how to install MariaDB 10.3 on CentOS 7. The current stable release of MariaDB is v10.3.15. Se how to install MariaDB 10.3 on Fedora 30 by following the link below;

Install MariaDB 10.3 on Fedora 30

Install MariaDB 10.3 on CentOS 7

Update and upgrade your system packages.

yum update
yum upgrade

Adding the MariaDB YUM repository

The latest stable version of MariaDB is not available on the default CentOS 7 repositories. Hence you need to add the YUM repository so as to install the latest version of MariaDB

cat > /etc/yum.repos.d/mariadb.10.3.repo << EOF
name = MariaDB
baseurl =

Next, run the system update again to resynchronize packages to their latest versions.

yum update -y

Install MariaDB 10.3 on CentOS 7

Once you have the MariaDB repos in place, proceed to do the installation of both MariaDB server and client by executing the commands below;

yum install mariadb mariadb-server
 Package                 Arch   Version                      Repository
 MariaDB-client          x86_64 10.3.15-1.el7.centos         mariadb  11 M
 MariaDB-server          x86_64 10.3.15-1.el7.centos         mariadb  24 M

Running MariaDB on CentOS 7

Once the installation is done, you can start and enable MariaDB to run on system boot by executing the commands below;

systemctl start mariadb
systemctl enable mariadb

Set MariaDB Root Password

To set the MariaDB root password, run the command below. Replace new-password with your password.

mysqladmin -u root password 'new-password'

The password can also be set using the MariaDB security script.

Initial MariaDB Security

MariaDB ships with a simple MariaDB security script, mysql_secure_installation, that basically enables you to remove test databases and anonymous user created by default. This is strongly recommended for production servers. This script can be simply run as;


The first prompt would be to set the root password. however, if you have set it above, just enter the password and proceed.

In order to log into MariaDB to secure it, we'll need the current
password for the root user.  If you've just installed MariaDB, and
you haven't set the root password yet, the password will be blank,
so you should just press enter here.

Enter current password for root (enter for none): 
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorisation.

You already have a root password set, so you can safely answer 'n'.

Change the root password? [Y/n] n

Next, remove the database anonymous user.

By default, a MariaDB installation has an anonymous user, allowing anyone
to log into MariaDB without having to have a user account created for
them.  This is intended only for testing, and to make the installation
go a bit smoother.  You should remove them before moving into a
production environment.

Remove anonymous users? [Y/n] y
 ... Success!

Disable remote root login

Normally, root should only be allowed to connect from 'localhost'.  This
ensures that someone cannot guess at the root password from the network.

Disallow root login remotely? [Y/n] 
 ... Success!

Remove test databases

By default, MariaDB comes with a database named 'test' that anyone can
access.  This is also intended only for testing, and should be removed
before moving into a production environment.

Remove test database and access to it? [Y/n] y
 - Dropping test database...
 ... Success!
 - Removing privileges on test database...
 ... Success!

Reload the privileges tables to effect the changes.

Reloading the privilege tables will ensure that all changes made so far
will take effect immediately.

Reload privilege tables now? [Y/n] y    
 ... Success!

That is all about the installation MariaDB 10.3.

To verify that you MariaDB is working fine, login and run some test queries. For example to check the version;

mysql -u root -p
MariaDB [(none)]> select version();
| version()       |
| 10.3.15-MariaDB |
1 row in set (0.003 sec)

MariaDB [(none)]>

Well, all is well now. You have successfully installed MariaDB on CentOS 7.

You can check our other guides by following the links below;

How to Install LEMP (Nginx,MariaDB,PHP7.2) Stack on Fedora 28 / Fedora 29

How To Setup LEMP Stack (Nginx, MariaDB, PHP 7.2) on Ubuntu 18.04

How to Install LAMP Stack (Apache,MariaDB, PHP 7.2) on Ubuntu 18.04 LTS

A Simple Way to Reset MySQL/MariaDB root Password

Install phpMyAdmin with Nginx on Fedora 30


We're passionate about sharing our knowledge and experiences with you through our blog. If you appreciate our efforts, consider buying us a virtual coffee. Your support keeps us motivated and enables us to continually improve, ensuring that we can provide you with the best content possible. Thank you for being a coffee-fueled champion of our work!

Photo of author
I am the Co-founder of, Linux and the whole FOSS enthusiast, Linux System Admin and a Blue Teamer who loves to share technological tips and hacks with others as a way of sharing knowledge as: "In vain have you acquired knowledge if you have not imparted it to others".

Leave a Comment