How to install Mariadb MySQL Server and Mariadb Client in Rhel 7 / Centos 7

In this article you will learn how to install MariaDB MySQL Server and MariaDB Client on RHEL 7 / CentOS 7. MariaDB MySQL Server is an open source database server application like Relational Database Management System (RDBMS) to create, update, delete and for other database related tasks. This is a database server like the MySQL database, and even the development of the MariaDB MySQL server application is only created by the MySQL team. The developers of MariaDB are MariaDB Corporation Ab and MariaDB Foundation first published the application on the year 2009 under GNU General Public License and promised to keep the application open source forever. MariaDB MySQL Server is a cross-platform application in the programming language C & C ++, which is available for almost all common operating systems such as Linux, Microsoft Windows, OS X, Solaris and FreeBSD.etc.

How to install MariaDB MySQL server and Mariadb client in Rhel 7 Centos 7

More information about MariaDB MySQL Server can be found on the official website HERE!

Perform the following steps to install MariaDB MySQL Server and MariaDB Client on RHEL 7 / CentOS 7:

Before we start installing MariaDB Mysql Server and MariaDB Client, we update the packages and repositories of CentOS 7 / RHEL 7 with the following command.

[[email protected] ~]# yum -y update   # Update Packages & Repositories

Now you can install MariaDB MySQL Server and the MariaDB client. We can install both packages with the yum repository. For installation information, see the following command.

[[email protected] ~]# yum -y install mariadb-server mariadb   # Install MariaDB MySQL Server & MariaDB Client
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base:
 * extras:
 * updates:
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.52-1.el7 will be installed
--> Processing Dependency: mariadb-libs(x86-64) = 1:5.5.52-1.el7 for package: 1:mariadb-5.5.52-1.el7.x86_64
---> Package mariadb-server.x86_64 1:5.5.52-1.el7 will be installed
--> Processing Dependency: perl-DBI for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Processing Dependency: perl-DBD-MySQL for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Processing Dependency: perl(Data::Dumper) for package: 1:mariadb-server-5.5.52-1.el7.x86_64
--> Processing Dependency: perl(DBI) for package: 1:mariadb-server-5.5.52-1.el7.x86_64
  mariadb.x86_64 1:5.5.52-1.el7                                                       mariadb-server.x86_64 1:5.5.52-1.el7                                                      

Dependency Installed:
  perl-Compress-Raw-Bzip2.x86_64 0:2.061-3.el7     perl-Compress-Raw-Zlib.x86_64 1:2.061-4.el7     perl-DBD-MySQL.x86_64 0:4.023-5.el7     perl-DBI.x86_64 0:1.627-4.el7        
  perl-Data-Dumper.x86_64 0:2.145-3.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    

Dependency Updated:
  mariadb-libs.x86_64 1:5.5.52-1.el7                                                                                                                                            


We have successfully installed the MariaDB MySQL server and MariaDB client packages. For information on starting the MariaDB service, see the following command.

[[email protected] ~]# systemctl start mariadb   # Start the MariaDB MySQL Server Service

To check whether the MariaDB MySQL Server service is running or not, you can use the following command.

[[email protected] ~]# systemctl status mariadb   # Confirm if MariaDB Service is Working or Not
● mariadb.service - MariaDB database server
   Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2017-08-06 13:01:56 IST; 23s ago
  Process: 20947 ExecStartPost=/usr/libexec/mariadb-wait-ready $MAINPID (code=exited, status=0/SUCCESS)
  Process: 20904 ExecStartPre=/usr/libexec/mariadb-prepare-db-dir %n (code=exited, status=0/SUCCESS)
 Main PID: 20946 (mysqld_safe)
   CGroup: /system.slice/mariadb.service
           ├─20946 /bin/sh /usr/bin/mysqld_safe --basedir=/usr
           └─21162 /usr/libexec/mysqld --basedir=/usr --datadir=/var/lib/mysql --plugin-dir=/usr/lib64/mysql/plugin --log-error=/var/log/mariadb/mariadb.log --pid-file=/var/...

Aug 06 13:01:54 localhost.localdomain systemd[1]: Starting MariaDB database server...
Aug 06 13:01:55 localhost.localdomain mysqld_safe[20946]: 170806 13:01:55 mysqld_safe Logging to '/var/log/mariadb/mariadb.log'.
Aug 06 13:01:55 localhost.localdomain mysqld_safe[20946]: 170806 13:01:55 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql
Aug 06 13:01:56 localhost.localdomain systemd[1]: Started MariaDB database server.

Read also: Step by step recovery of a forgotten MySQL root password

For information on how to enable MariaDB MySQL Server service on startup, see the following command.

[[email protected] ~]# systemctl enable mariadb   # Enable the MariaDB Service on Startup 
Created symlink from /etc/systemd/system/ to /usr/lib/systemd/system/mariadb.service.

Use the following command to confirm the installed MariaDB Server and MariaDB Client package.

[[email protected] ~]# rpm -qa | grep mariadb   # Confirm the installed Package

To check the version of the MariaDB that installed the package, we can use the following command.

[[email protected] ~]# mysql --version;   # Check Version of MariaDB Database Server Package Version
mysql  Ver 15.1 Distrib 5.5.52-MariaDB, for Linux (x86_64) using readline 5.1

In order to configure the MariaDB MySQL server as follows, set a root password for the MySQL server, remove anonymous users, prohibit remote login of the root … etc., we can use that mysql_secure_installation Command.

[[email protected] ~]# mysql_secure_installation   # Configuring MariaDB Mysql Server


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):  ---> Just Press ENTER to continue as currently we don't have any root password
OK, successfully used password, moving on...

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

Set root password? [Y/n] y         # Enter "y" to Set root Password
New password: 
Re-enter new password: 
Password updated successfully!
Reloading privilege tables..
 ... Success!

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   ---> Enter "y" If you want to remove Anonymous Users to login MariaDB MySQL Server
 ... 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  ---> Enter "y" to Disable root Login of MariaDB Database Server on Remote Access
 ... 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  ---> Enter "y" to remove all test Database's and access to it from MariaDB MySQL Server
 - 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   ---> Enter "y" reload Privilege Table
 ... 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!

Read also: How to install LAMP Stack with PhpMyAdmin in Ubuntu 18.04

We have successfully installed and configured the MariaDB MySQL Server & MariaDB Client. Now let’s log in to the MySQL server.

[[email protected] ~]# mysql -u root -p   # Login MariaDB MySQL server using "root"
Enter password:     ---> Enter the Password of user "root"
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 10
Server version: 5.5.52-MariaDB MariaDB Server

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

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

MariaDB [(none)]> create database usersdb;   # Create a New Database
Query OK, 1 row affected (0.00 sec)

MariaDB [(none)]> show databases;   # Show available Database's
| Database           |
| information_schema |
| mysql              |
| performance_schema |
| usersdb            |
4 rows in set (0.00 sec)

MariaDB [(none)]> use usersdb;   # Changing the Database
Database changed
MariaDB [usersdb]> CREATE TABLE employees (employee_id int, name VARCHAR(15), address VARCHAR(300));
Query OK, 0 rows affected (0.01 sec)

MariaDB [usersdb]> show tables;   # Show available Table's in Database
| Tables_in_usersdb |
| employees         |
1 row in set (0.00 sec)

# Insert Data in to the Table "employees"

MariaDB [usersdb]> INSERT INTO employees (employee_id,name,address) VALUES(001,"shrikant","mumbai");
Query OK, 1 row affected (0.00 sec)

MariaDB [usersdb]> INSERT INTO employees (employee_id,name,address) VALUES(002,"aditya","delhi");
Query OK, 1 row affected (0.00 sec)

MariaDB [usersdb]> SELECT * FROM employees;   # Retrieving Data from Table "employees"
| employee_id | name     | address |
|           1 | shrikant | mumbai  |
|           2 | aditya   | delhi   |
2 rows in set (0.00 sec)

That’s all. In this article we have explained how to install Mariadb MySQL Server and Mariadb Client In Rhel 7 / Centos 7. I hope you like this article. If you like this article, just share it. If you have any questions about this article, please comment.