MariaDB server is a community developed fork of MySQL server. MariaDB is a backward compatible, drop-in replacement of the MySQL Database Server and it includes all major open source storage engines..

Started by core members of the original MySQL team, MariaDB actively works with outside developers to deliver  more feature, new storage engines, fewer bugs and better performance. MariaDB is the best choice for database professionals looking for a robust, scalable, and reliable SQL server.

This article will teach you how to install MariaDB on a CentOS 7 / RHEL 7 server.


Add MariaDB Yum repository

Create a new repo file /etc/yum.repos.d/mariadb.repo and add the below code changing the base url according to the operating system version and architecture:

# vi /etc/yum.repos.d/mariadb.repo
name = MariaDB
baseurl =


Install MariaDB Server

Run the following command to install MariaDB 10.3:

# yum install MariaDB-server MariaDB-client
Loaded plugins: fastestmirror
Determining fastest mirrors
* base: mirrors......
* extras: mirrors.....
* updates: mirrors......
base | 3.6 kB 00:00:00
extras | 2.9 kB 00:00:00
mariadb | 2.9 kB 00:00:00
updates | 2.9 kB 00:00:00
(1/5): base/7/x86_64/group_gz | 153 kB 00:00:00
(2/5): extras/7/x86_64/primary_db | 205 kB 00:00:00
(3/5): updates/7/x86_64/primary_db | 3.0 MB 00:00:00
(4/5): base/7/x86_64/primary_db | 6.1 MB 00:00:00
(5/5): mariadb/primary_db | 54 kB 00:00:00
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.3.23-1.el7.centos will be installed
--> Processing Dependency: for package: MariaDB-client-10.3.23-1.el7.centos.x86_64
--> Processing Dependency: MariaDB-common for package: MariaDB-client-10.3.23-1.el7.centos.x86_64
--> Processing Dependency: for package: MariaDB-client-10.3.23-1.el7.centos.x86_64
--> Processing Dependency: for package: MariaDB-client-10.3.23-1.el7.centos.x86_64
---> Package MariaDB-server.x86_64 0:10.3.23-1.el7.centos will be installed
--> Processing Dependency: galera for package: MariaDB-server-10.3.23-1.el7.centos.x86_64
--> Processing Dependency: perl(DBI) for package: MariaDB-server-10.3.23-1.el7.centos.x86_64
--> Running transaction check
---> Package MariaDB-common.x86_64 0:10.3.23-1.el7.centos will be installed
--> Processing Dependency: MariaDB-compat for package: MariaDB-common-10.3.23-1.el7.centos.x86_64
---> Package galera.x86_64 0:25.3.29-1.rhel7.el7.centos will be installed
--> Processing Dependency: for package: galera-25.3.29-1.rhel7.el7.centos.x86_64
---> Package libaio.x86_64 0:0.3.109-13.el7 will be installed
---> Package perl-DBI.x86_64 0:1.627-4.el7 will be installed
--> Processing Dependency: perl(RPC::PlServer) >= 0.2001 for package: perl-DBI-1.627-4.el7.x86_64
--> Processing Dependency: perl(RPC::PlClient) >= 0.2000 for package: perl-DBI-1.627-4.el7.x86_64
--> Running transaction check
---> Package MariaDB-compat.x86_64 0:10.3.23-1.el7.centos will be obsoleting
---> Package boost-program-options.x86_64 0:1.53.0-28.el7 will be installed
---> Package mariadb-libs.x86_64 1:5.5.60-1.el7_5 will be obsoleted
---> Package perl-PlRPC.noarch 0:0.2020-14.el7 will be installed
--> Processing Dependency: perl(Net::Daemon) >= 0.13 for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Test) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Net::Daemon::Log) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Processing Dependency: perl(Compress::Zlib) for package: perl-PlRPC-0.2020-14.el7.noarch
--> Running transaction check
---> Package perl-IO-Compress.noarch 0:2.061-2.el7 will be installed
--> Processing Dependency: perl(Compress::Raw::Zlib) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
--> Processing Dependency: perl(Compress::Raw::Bzip2) >= 2.061 for package: perl-IO-Compress-2.061-2.el7.noarch
---> Package perl-Net-Daemon.noarch 0:0.48-5.el7 will be installed
--> Running transaction check
---> Package perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 will be installed
---> Package perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

Package Arch Version Repository Size
MariaDB-client x86_64 10.3.23-1.el7.centos mariadb 11 M
MariaDB-compat x86_64 10.3.23-1.el7.centos mariadb 2.2 M
replacing mariadb-libs.x86_64 1:5.5.60-1.el7_5
MariaDB-server x86_64 10.3.23-1.el7.centos mariadb 24 M
Installing for dependencies:
MariaDB-common x86_64 10.3.23-1.el7.centos mariadb 81 k
boost-program-options x86_64 1.53.0-28.el7 base 156 k
galera x86_64 25.3.29-1.rhel7.el7.centos mariadb 8.2 M
libaio x86_64 0.3.109-13.el7 base 24 k
perl-Compress-Raw-Bzip2 x86_64 2.061-3.el7 base 32 k
perl-Compress-Raw-Zlib x86_64 1:2.061-4.el7 base 57 k
perl-DBI x86_64 1.627-4.el7 base 802 k
perl-IO-Compress noarch 2.061-2.el7 base 260 k
perl-Net-Daemon noarch 0.48-5.el7 base 51 k
perl-PlRPC noarch 0.2020-14.el7 base 36 k

Transaction Summary
Install 3 Packages (+10 Dependent packages)

Total download size: 47 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7/mariadb/packages/MariaDB-common-10.3.23-1.el7.centos.x86_64.rpm: Header V4 DSA/SHA1 Signature, key ID 1bb943db: NOKEY ] 0.0 B/s | 56 kB --:--:-- ETA
Public key for MariaDB-common-10.3.23-1.el7.centos.x86_64.rpm is not installed
(1/13): MariaDB-common-10.3.23-1.el7.centos.x86_64.rpm | 81 kB 00:00:00
(2/13): MariaDB-compat-10.3.23-1.el7.centos.x86_64.rpm | 2.2 MB 00:00:02
warning: /var/cache/yum/x86_64/7/base/packages/boost-program-options-1.53.0-28.el7.x86_64.rpm: Header V3 RSA/SHA256 Signature, key ID f4a80eb5: NOKEY
Public key for boost-program-options-1.53.0-28.el7.x86_64.rpm is not installed
(3/13): boost-program-options-1.53.0-28.el7.x86_64.rpm | 156 kB 00:00:00
(4/13): MariaDB-server-10.3.23-1.el7.centos.x86_64.rpm | 24 MB 00:00:08
(5/13): libaio-0.3.109-13.el7.x86_64.rpm | 24 kB 00:00:00
(6/13): perl-DBI-1.627-4.el7.x86_64.rpm | 802 kB 00:00:00
(7/13): perl-IO-Compress-2.061-2.el7.noarch.rpm | 260 kB 00:00:00
(8/13): perl-Net-Daemon-0.48-5.el7.noarch.rpm | 51 kB 00:00:00
(9/13): perl-PlRPC-0.2020-14.el7.noarch.rpm | 36 kB 00:00:00
(10/13): perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64.rpm | 32 kB 00:00:00
(11/13): perl-Compress-Raw-Zlib-2.061-4.el7.x86_64.rpm | 57 kB 00:00:00
(12/13): MariaDB-client-10.3.23-1.el7.centos.x86_64.rpm | 11 MB 00:00:14
(13/13): galera-25.3.29-1.rhel7.el7.centos.x86_64.rpm | 8.2 MB 00:00:07
Total 2.4 MB/s | 47 MB 00:00:19
Retrieving key from
Importing GPG key 0x1BB943DB:
Userid : "MariaDB Package Signing Key <>"
Fingerprint: 1993 69e5 404b d5fc 7d2f e43b cbcb 082a 1bb9 43db
From :
Is this ok [y/N]: y
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Importing GPG key 0xF4A80EB5:
Userid : "CentOS-7 Key (CentOS 7 Official Signing Key) <>"
Fingerprint: 6341 ab27 53d7 8a78 a7c2 7bb1 24c6 a8a7 f4a8 0eb5
Package : centos-release-7-6.1810.2.el7.centos.x86_64 (installed)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-CentOS-7
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : MariaDB-compat-10.3.23-1.el7.centos.x86_64 1/14
Installing : MariaDB-common-10.3.23-1.el7.centos.x86_64 2/14
Installing : libaio-0.3.109-13.el7.x86_64 3/14
Installing : MariaDB-client-10.3.23-1.el7.centos.x86_64 4/14
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 5/14
Installing : boost-program-options-1.53.0-28.el7.x86_64 6/14
Installing : galera-25.3.29-1.rhel7.el7.centos.x86_64 7/14
Installing : perl-Net-Daemon-0.48-5.el7.noarch 8/14
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 9/14
Installing : perl-IO-Compress-2.061-2.el7.noarch 10/14
Installing : perl-PlRPC-0.2020-14.el7.noarch 11/14
Installing : perl-DBI-1.627-4.el7.x86_64 12/14
Installing : MariaDB-server-10.3.23-1.el7.centos.x86_64 13/14

To do so, start the server, then issue the following commands:

'/usr/bin/mysqladmin' -u root password 'new-password'
'/usr/bin/mysqladmin' -u root -h password 'new-password'

Alternatively you can run:

which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.

See the MariaDB Knowledgebase at or the
MySQL manual for more instructions.

Please report any problems at

The latest information about MariaDB is available at
You can find additional information about the MySQL part at:
Consider joining MariaDB's strong and vibrant community:
Get Involved
Failed to resolve typeattributeset statement at /etc/selinux/targeted/tmp/modules/400/mariadb/cil:1 /usr/sbin/semodule: Failed! Erasing : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 14/14 Verifying : MariaDB-common-10.3.23-1.el7.centos.x86_64 1/14 Verifying : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64 2/14 Verifying : perl-Net-Daemon-0.48-5.el7.noarch 3/14 Verifying : boost-program-options-1.53.0-28.el7.x86_64 4/14 Verifying : MariaDB-server-10.3.23-1.el7.centos.x86_64 5/14 Verifying : MariaDB-compat-10.3.23-1.el7.centos.x86_64 6/14 Verifying : galera-25.3.29-1.rhel7.el7.centos.x86_64 7/14 Verifying : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64 8/14 Verifying : perl-DBI-1.627-4.el7.x86_64 9/14 Verifying : libaio-0.3.109-13.el7.x86_64 10/14 Verifying : MariaDB-client-10.3.23-1.el7.centos.x86_64 11/14 Verifying : perl-PlRPC-0.2020-14.el7.noarch 12/14 Verifying : perl-IO-Compress-2.061-2.el7.noarch 13/14 Verifying : 1:mariadb-libs-5.5.60-1.el7_5.x86_64 14/14 Installed: MariaDB-client.x86_64 0:10.3.23-1.el7.centos MariaDB-compat.x86_64 0:10.3.23-1.el7.centos MariaDB-server.x86_64 0:10.3.23-1.el7.centos Dependency Installed: MariaDB-common.x86_64 0:10.3.23-1.el7.centos boost-program-options.x86_64 0:1.53.0-28.el7 galera.x86_64 0:25.3.29-1.rhel7.el7.centos libaio.x86_64 0:0.3.109-13.el7 perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7 perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7 perl-DBI.x86_64 0:1.627-4.el7 perl-IO-Compress.noarch 0:2.061-2.el7 perl-Net-Daemon.noarch 0:0.48-5.el7 perl-PlRPC.noarch 0:0.2020-14.el7 Replaced: mariadb-libs.x86_64 1:5.5.60-1.el7_5 Complete!

When the installation is complete, run the following command to enable and start the daemon:

# systemctl enable mysql.service
# systemctl start mysql.service


Secure MariaDB install

MariaDB includes a security script called “mysql_secure_installation”, to change some of the less secure default options –  like removing remote root logins  and anonymous user.


Working with MariaDB

Once the configuration process is complete, connect to the MariaDB server by using the following command:

# mysql -u root -p

Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 16
Server version: 10.3.2-MariaDB MariaDB Server

Copyright (c) 2000, 2017, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

Display the complete list of the databases:

MariaDB [(none)]> SHOW DATABASES;
Let’s create a new database:
MariaDB [(none)]> CREATE DATABASE first_db;

Switch to a database:

MariaDB [(none)]> USE first_db;

Display all tables from a database:

MariaDB [(none)]> SHOW TABLES;

Delete a database:

MariaDB [(none)]> DROP DATABASE first_db;

Create a database user account:

MariaDB [(none)]> CREATE USER 'dbuser'@'localhost' IDENTIFIED BY 'Password';

Grant permissions on the database “first_db” for the new user “dbuser”, the bellow command allows the user “dbuser” to read, edit, execute and perform all tasks across the database “first_db”:

MariaDB [(none)]> GRANT ALL ON first_db.* TO 'dbuser'@'localhost';

Once the permissions are granted for your new users, reload all the privileges using the following command: