How To Install Mariadb MySQL Server And Mariadb Client In Rhel 7 / Centos 7

In this article, we are going to learn how to install MariaDB MySQL Server & MariaDB Client on RHEL 7/CentOS 7. MariaDB MySQL Server is an opensource Database server application like Relational Database Management System (RDBMS) used to Create, Update, Delete and other database-related tasks. This is a database server like MySQL database and even the development of MariaDB MySQL server application is created by the MySQL team only. The developers of MariaDB is MariaDB Corporation Ab and MariaDB Foundation initially released 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 written in C & C++ programming language, available for almost all major operating systems like Linux, Microsoft Windows, OS X, Solaris, FreeBSD.etc.

How To Install Mariadb Mysql Server And Mariadb Client In Rhel 7 Centos 7
How To Install MariaDB Mysql Server And Mariadb Client In Rhel 7 Centos 7

For more Information on MariaDB MySQL Server visit the official website HERE!

Follow the below steps to install MariaDB MySQL Server & MariaDB Client on RHEL 7/ CentOS 7 :

Before we start the installation of MariaDB Mysql Server and MariaDB Client let’s update the packages and repositories of CentOS 7/RHEL 7 using the below command.

[root@localhost ~]# yum -y update   # Update Packages & Repositories

Now let’s go ahead and install MariaDB MySQL Server and MariaDB client. We can install both packages using the yum Repository. Refer to the command below to install the same.

[root@localhost ~]# yum -y install mariadb-server mariadb   # Install MariaDB MySQL Server & MariaDB Client
Loaded plugins: fastestmirror, langpacks
Loading mirror speeds from cached hostfile
 * base: centos.mirror.net.in
 * extras: ftp.iitm.ac.in
 * updates: ftp.iitm.ac.in
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
.
.
.
Installed:
  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                                                                                                                                            

Complete!

We have successfully installed the MariaDB MySQL server & MariaDB client Packages. To start the MariaDB Service refer to the below command.

[root@localhost ~]# systemctl start mariadb   # Start the MariaDB MySQL Server Service

To confirm if the MariaDB MySQL Server service is running or not you can use the below command.

[root@localhost ~]# 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.

Also Read : Step By Step Recover Forgotten Mysql Root Password

To enable the MariaDB MySQL Server service on startup refer to the below command.

[root@localhost ~]# systemctl enable mariadb   # Enable the MariaDB Service on Startup 
Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

To confirm the installed package of MariaDB Server and MariaDB client use the below command.

[root@localhost ~]# rpm -qa | grep mariadb   # Confirm the installed Package
mariadb-5.5.52-1.el7.x86_64
mariadb-server-5.5.52-1.el7.x86_64
mariadb-libs-5.5.52-1.el7.x86_64

To check the version of the MariaDB installed the package we can use the below command.

[root@localhost ~]# 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

Now to configure the MariaDB MySQL Server like, set a root password for MySQL server, remove anonymous users, Disallow root login remotely…etc, we can use the mysql_secure_installation command.

[root@localhost ~]# mysql_secure_installation   # Configuring MariaDB Mysql Server

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
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!

Also ReadHow to Install LAMP Stack with PhpMyAdmin in Ubuntu.

So we have successfully installed and configure the MariaDB MySQL Server & MariaDB client. Now let’s log in the MySQL server.

[root@localhost ~]# 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 enjoy this article. If you like this article, then just share it. If you have any questions about this article, please comment.

Share this:
WhatsApp Channel Join Now
Telegram Channel Join Now
Instagram Channel Join Now

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.