How to install Install MariaDB 10.2 Centos 7


In this article we shall learn about – how to install MariaDB 10.2 on Centos 7 / RHEL. This can be used as a guide for beginners or as a reference.  Please note that, this can also be used as an alternative replacement of MySQL.

Features of MariaDB

  • MariaDB is an open-source and an alternative relational database management software.
  • MariaDB is robust, fast and Scalable with rich storage engines.
  • MariaDB has new features such as GIS and JSON.

Server Information and Packages

  • The Package included: MariadB, Mariadb-server,MariaDB-libs.
  • The Daemon Name used is: mariadb.
  • Port No: 3306.
  • Configuration path: /etc/my.cnf.

Installing Maria DB 10.2 on Centos 7 / RHEL 7

In general, the mariaDB package comes with an installation media in the local repository which we can install, but if we needed to install the latest package we can do it by adding the repository to the yum local repository list. We use this below command and code to add the repository to the yum.

Adding Repo to Yum for MariaDB Installation

Adding the Repo for Centos 7 64 bit

[mariadb]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/centos7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Adding the Repo for RHEL 7 64 bit

[mariadb10]
name = MariaDB
baseurl = http://yum.mariadb.org/10.2/rhel7-amd64
gpgkey=https://yum.mariadb.org/RPM-GPG-KEY-MariaDB
gpgcheck=1

Installing MariaDB using Yum Repo’s

We can install the MariaDB using the Yum Repo, as we just added the repository to the local yum below is the command to install the mariaDB using the Yum

# yum groupinstall mariadb*
Loaded plugins: fastestmirror, refresh-packagekit, security
Loading mirror speeds from cached hostfile
 * base: ftp.iitm.ac.in
 * extras: ftp.iitm.ac.in
 * updates: ftp.iitm.ac.in
....
....
.....
....
....
...
....
Downloading packages:
--------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                        68 MB/s |  22 MB  00:00:00
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Warning: RPMDB altered outside of yum.
Installing : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                     1/13
Installing : unixODBC-2.3.1-10.el7.x86_64                                                                                            2/13
Installing : perl-Net-Daemon-0.48-5.el7.noarch                                                                                       3/13
Installing : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                             4/13
Installing : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                              5/13
Installing : perl-IO-Compress-2.061-2.el7.noarch                                                                                     6/13
Installing : perl-PlRPC-0.2020-14.el7.noarch                                                                                         7/13
Installing : perl-DBI-1.627-4.el7.x86_64                                                                                             8/13
Installing : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                       9/13
Installing : 1:mariadb-5.5.41-2.el7_0.x86_64                                                                                        10/13
Installing : 1:mariadb-server-5.5.41-2.el7_0.x86_64                                                                                 11/13
Installing : mysql-connector-odbc-5.2.5-6.el7.x86_64                                                                                12/13
Installing : MySQL-python-1.2.3-11.el7.x86_64                                                                                       13/13
Verifying  : 1:mariadb-5.5.41-2.el7_0.x86_64                                                                                         1/13
Verifying  : perl-Compress-Raw-Bzip2-2.061-3.el7.x86_64                                                                              2/13
Verifying  : mysql-connector-odbc-5.2.5-6.el7.x86_64                                                                                 3/13
Verifying  : perl-Data-Dumper-2.145-3.el7.x86_64                                                                                     4/13
Verifying  : MySQL-python-1.2.3-11.el7.x86_64                                                                                        5/13
Verifying  : 1:mariadb-server-5.5.41-2.el7_0.x86_64                                                                                  6/13
Verifying  : 1:perl-Compress-Raw-Zlib-2.061-4.el7.x86_64                                                                             7/13
Verifying  : perl-PlRPC-0.2020-14.el7.noarch                                                                                         8/13
Verifying  : perl-Net-Daemon-0.48-5.el7.noarch                                                                                       9/13
Verifying  : perl-DBI-1.627-4.el7.x86_64                                                                                            10/13
Verifying  : unixODBC-2.3.1-10.el7.x86_64                                                                                           11/13
Verifying  : perl-DBD-MySQL-4.023-5.el7.x86_64                                                                                      12/13
Verifying  : perl-IO-Compress-2.061-2.el7.noarch                                                                                    13/13
Installed:
MySQL-python.x86_64 0:1.2.3-11.el7                mariadb.x86_64 1:5.5.41-2.el7_0         mariadb-server.x86_64 1:5.5.41-2.el7_0
mysql-connector-odbc.x86_64 0:5.2.5-6.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               unixODBC.x86_64 0:2.3.1-10.el7
Complete!

Starting the MariaDB Services

Below is the command to start the mariaDB services

# systemctl start mariadb.services

And we needed to add the services to start services  at the boot time, we can use the below command to start the mariaDB services at the boot time.

# systemctl enable mariadb.services

Adding the MariaDB ports to allow from Firewall

# firewall-cmd –permanent –add-services=mysql
# firewall-cmd –permanent –add-port=3306/tcp
# firewall-cmd –reload

Securing the mariadb and Setting the Root User Password

By default, the root password for the mariadb is not set and without root password, we cannot log into the database server. Below is the command to set the root password for mariaDB and remove the anonymous users and secure the mariaDB by restricting the remote login for root and remove the test database.

# mysql_secure_installation
/usr/bin/mysql_secure_installation: line 379: find_mysql_client: command not found
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):
OK, successfully used password, moving on...
Setting the root password ensures that nobody can log into the MariaDB
root user without the proper authorization.
Set root password? [Y/n] y
New password:
Re-enter new password:
Password updated successfully!
Reloading the 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
... 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. Install MariaDB 10.2 RHEL 7
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. Install MariaDB 10.2 RHEL 7
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!

Testing the Connection to the MariaDB.

As we have completed the installation and assigned a password for the root user and secure the connection, we needed to test the mariadb by logging into the database. Below is the command to test the mariaDB –

# mysql -uroot -p
Enter password:
Welcome to the MariaDB monitor.  Commands end with; or \g.
Your MariaDB connection id is 10
Server version: 5.5.41-MariaDB MariaDB Server Install MariaDB 10.2 RHEL 7
Copyright (c) 2000, 2014, Oracle, MariaDB Corporation Ab and others.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

By using the above steps, we can install the MariadDB 10.2 on CentOS 7 / RHEL 7 and secure the mariadb by removing the anonymous user and test database which is a good alternative replacement of MySQL server. In our future articles, you will learn more about MariaDB.

Advertisements