Install MariaDB 10.7 on CentOS 7

This article is going to teach you how to install MariaDB 10.7 on CentOS 7. MariaDB is a MySQL fork. To put it another way, it’s a better, drop-in substitute for MySQL. A drop-in replacement means that you may use the analog version of the MariaDB server to replace the regular MySQL server and benefit from all of MariaDB’s advancements without having to change your application code.

MariaDB is a fast, scalable, and reliable database. It has a larger number of storage engines than MySQL. MariaDB also comes with a slew of plugins and utilities that make it adaptable to a wide range of scenarios.

How to Install MariaDB 10.7 on CentOS 7

  • Lets start by adding MariaDB YUM repository on CentOS 7. Note, If you’re using another MySQL-based database management system, you’ll need to uninstall it first before proceeding with this installation.
  1. Add MariaDB YUM repository
  2. Install MariaDB 10.7 on CentOS 7
  3. Secure MariaDB in CentOS 7
  4. Connect to MariaDB

Add MariaDB YUM repository

  • Run the command below to add MariaDB YUM repository.
curl -LsS -O https://downloads.mariadb.com/MariaDB/mariadb_repo_setup
sudo bash mariadb_repo_setup --mariadb-server-version=10.7

Sample Output

# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.7 is valid
# [info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo
# [info] Adding trusted package signing keys...
/etc/pki/rpm-gpg /home/kigz
/home/kigz
# [info] Successfully added trusted package signing keys
# [info] Cleaning package cache...
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras mariadb-main mariadb-maxscale mariadb-tools remi-php74 remi-safe updates
Cleaning up list of fastest mirrors

Install MariaDB 10.7 on CentOS 7

  • After you’ve added the MariaDB repository, we may now proceed with the installation of MariaDB 10.7 on CentOS 7
sudo yum install MariaDB-server MariaDB-client -y

Sample Output

# [info] Checking for script prerequisites.
# [info] MariaDB Server version 10.7 is valid
# [info] Repository file successfully written to /etc/yum.repos.d/mariadb.repo
# [info] Adding trusted package signing keys...
/etc/pki/rpm-gpg /home/kigz
/home/kigz
# [info] Successfully added trusted package signing keys
# [info] Cleaning package cache...
Loaded plugins: fastestmirror, langpacks
Cleaning repos: base epel extras mariadb-main mariadb-maxscale mariadb-tools remi-php74 remi-safe updates
Cleaning up list of fastest mirrors
[[email protected] ~]$ yum install MariaDB-server MariaDB-client -y
Loaded plugins: fastestmirror, langpacks
You need to be root to perform this command.
[[email protected] ~]$ sudo yum install MariaDB-server MariaDB-client -y
[sudo] password for kigz: 
Loaded plugins: fastestmirror, langpacks
Determining fastest mirrors
epel/x86_64/metalink                                                                                        |  36 kB  00:00:00     
 * base: centos.mirror.liquidtelecom.com
 * epel: d2lzkl7pfhq30w.cloudfront.net
 * extras: centos.mirror.liquidtelecom.com
 * remi-php74: remirepo.reloumirrors.net
 * remi-safe: remirepo.reloumirrors.net
 * updates: centos.mirror.liquidtelecom.com
base                                                                                                        | 3.6 kB  00:00:00     
epel                                                                                                        | 4.7 kB  00:00:00     
extras                                                                                                      | 2.9 kB  00:00:00     
mariadb-main                                                                                                | 3.4 kB  00:00:00     
mariadb-maxscale                                                                                            | 2.5 kB  00:00:00     
mariadb-tools                                                                                               | 2.9 kB  00:00:00     
remi-php74                                                                                                  | 3.0 kB  00:00:00     
remi-safe                                                                                                   | 3.0 kB  00:00:00     
updates                                                                                                     | 2.9 kB  00:00:00     
(1/13): epel/x86_64/group_gz                                                                                |  96 kB  00:00:00     
(2/13): base/7/x86_64/group_gz                                                                              | 153 kB  00:00:01     
(3/13): base/7/x86_64/primary_db                                                                            | 6.1 MB  00:00:01     
(4/13): extras/7/x86_64/primary_db                                                                          | 243 kB  00:00:01     
(5/13): epel/x86_64/updateinfo                                                                              | 1.0 MB  00:00:03     
(6/13): epel/x86_64/primary_db                                                                              | 7.0 MB  00:00:04     
(7/13): mariadb-main/updateinfo                                                                             | 4.9 kB  00:00:02     
(8/13): mariadb-tools/primary_db                                                                            |  17 kB  00:00:01     
(9/13): mariadb-maxscale/primary_db                                                                         | 7.1 kB  00:00:02     
(10/13): mariadb-main/primary_db                                                                            |  55 kB  00:00:03     
(11/13): updates/7/x86_64/primary_db                                                                        |  13 MB  00:00:02     
(12/13): remi-php74/primary_db                                                                              | 254 kB  00:00:02     
(13/13): remi-safe/primary_db                                                                               | 2.1 MB  00:00:09     
Resolving Dependencies
--> Running transaction check
---> Package MariaDB-client.x86_64 0:10.7.3-1.el7.centos will be installed
  • You can check details about the version you just installed using the command below.
rpm -qi MariaDB-server
  • Next, run the command below to start MariaDB
systemctl start mariadb
  • Then enable it using the following command.
systemctl enable mariadb
  • You can check its status using the command below.
systemctl status mariadb

Sample output

● mariadb.service - MariaDB 10.7.3 database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; vendor preset: disabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
           └─migrated-from-my.cnf-settings.conf
   Active: active (running) since Fri 2022-02-18 19:24:07 EAT; 2min 7s ago
     Docs: man:mariadbd(8)
           https://mariadb.com/kb/en/library/systemd/
 Main PID: 15591 (mariadbd)
   Status: "Taking your SQL requests now..."
   CGroup: /system.slice/mariadb.service
           └─15591 /usr/sbin/mariadbd

Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] InnoDB: File './ibtmp1' size is now 12 MB.
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] InnoDB: 10.7.3 started; log sequence number 413... id 14
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] Plugin 'FEEDBACK' is disabled.
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] InnoDB: Loading buffer pool(s) from /var/lib/my...r_pool
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] Server socket created on IP: '0.0.0.0'.
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] Server socket created on IP: '::'.
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] InnoDB: Buffer pool(s) load completed at 220218 19:24:07
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: 2022-02-18 19:24:07 0 [Note] /usr/sbin/mariadbd: ready for connections.
Feb 18 19:24:07 localhost.localdomain mariadbd[15591]: Version: '10.7.3-MariaDB'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  ...Server
Feb 18 19:24:07 localhost.localdomain systemd[1]: Started MariaDB 10.7.3 database server.
Hint: Some lines were ellipsized, use -l to show in full.

Secure MariaDB on CentOS 7

  • Run the command below to secure your MariaDB.
sudo mariadb-secure-installation

Sample output

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB
      SERVERS IN PRODUCTION USE!  PLEASE READ EACH STEP CAREFULLY!

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
haven't set the root password yet, you should just press enter here.

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

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

You already have your root account protected, so you can safely answer 'n'.

Switch to unix_socket authentication [Y/n] y
Enabled successfully!
Reloading privilege tables..
 ... Success!


You already have your root account protected, so you can safely answer 'n'.

Change the root password? [Y/n] n
 ... skipping.

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!

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] y
 ... Success!

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!

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

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

Cleaning up...

All done!  If you've completed all of the above steps, your MariaDB
installation should now be secure.

Thanks for using MariaDB!

Connect to MariaDB

  • You can now use your root password to access MariaDB. Run the command below to do so
sudo mysql -u root

Sample output

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

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

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

MariaDB [(none)]> 
  • You are done installing MariaDB on CentOS 7, you can now create your databases.
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 14
Server version: 10.7.3-MariaDB MariaDB Server

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

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

MariaDB [(none)]> CREATE DATABASE itnixpro;
Query OK, 1 row affected (0.001 sec)

MariaDB [(none)]> SHOW DATABASES;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| itnixpro           |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
5 rows in set (0.002 sec)

MariaDB [(none)]> 
  • Congratulations you have reached the end of the article. You have learned how to Install MariaDB 10.7 on CentOS 7.

Other Tutorials

Install WordPress with LAMP Stack on Ubuntu 22.04

Install WordPress with LEMP Stack on Ubuntu 22.04

Install Webmin on Ubuntu 22.04

System administrator | Software Developer | DevOps

Leave a Comment