In this tutorial we will learn, how to install MariaDB Server on CentOS 7 / RHEL 7 . Before the stable release of RHEL 7, it was confirmed the MariaDB will be default database. This is one of the major changes we have observed in this RHEL 7/CentOS 7 stable release.
Whereas MySQL server still available and can be installed on RHEL 7 /CentOS 7 . (Read this How To)

Although at the time of writing this post, MariaDB 10.0.12 Stable release is available (Dated on 2014-06-16) , yet we will install it by simply using yum command from default yum repo.

Install MariaDB Server

To install MariaDB Server and MariaDB client. Use the below given command

yum install mariadb-server mariadb

After installation, we have checked the version of MariaDB Server. Given below is the detail
Server version: 5.5.37-MariaDB MariaDB Server

We queried the list of rpm packages related to MariaDB and given below is the result

[root@localhost ~]# rpm -qa|grep -i maria
mariadb-5.5.37-1.el7_0.x86_64
mariadb-server-5.5.37-1.el7_0.x86_64
mariadb-libs-5.5.37-1.el7_0.x86_64
[root@localhost ~]#

Now start the MariaDB Server . Bydefault it is not started.

systemctl start mariadb.service

Start/Stop/Restart/Status MariaDB Server

To start MariaDB Server

systemctl start mariadb.service

To stop MariaDB Server

systemctl stop mariadb.service

To restart MariaDB Server

systemctl restart mariadb.service

To get status of MariaDB Server

systemctl status mariadb.service

Enable MariaDB Server at booting time

systemctl enable mariadb.service

Disable MariaDB Server at booting time

systemctl disable mariadb.service

To know active status of MariaDB Server.

systemctl is-active mariadb.service

Reset the blank root password of MariaDB Server [Very Important]

After fresh installation of MariaDB Server, the database root user’s password is blank.
For security reason it is very important to reset the root’s blank password.

See below given reference, where without database root password we are able to login

[root@localhost ~]# mysql -u root
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 3
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> 

Method 1 : By using mysql_secure_installation command

Simply run the command mysql_secure_installation on your terminal. And follow the instruction. In beginning it will ask you to reset root password. We generally recommend this easy command after doing fresh installation of MariaDB Server.

The below given is reference from our server

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

Set root password? [Y/n] y
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
 ... 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!
[root@localhost ~]# 

Method 2: Reset root password by login into MariaDB Server

In this method we will login into MariaDB Server and then reset the root password.

mysql -u root

You will get the Mariadb prompt like this: MariaDB [(none)]>

Now run below given command in MariaDB server to reset root password.

use mysql;
update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root';
flush privileges;
quit

Given below is reference from our server

[root@localhost ~]# mysql -u root 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 10
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> 
MariaDB [(none)]> use mysql;
Reading table information for completion of table and column names
You can turn off this feature to get a quicker startup with -A

Database changed
MariaDB [mysql]> update user set password=PASSWORD("GIVE-NEW-ROOT-PASSWORD") where User='root';
Query OK, 3 rows affected (0.00 sec)
Rows matched: 3  Changed: 3  Warnings: 0

MariaDB [mysql]> flush privileges;
Query OK, 0 rows affected (0.00 sec)

MariaDB [mysql]> quit
Bye
[root@localhost ~]# 
[root@localhost ~]# mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 11
Server version: 5.5.37-MariaDB MariaDB Server

Copyright (c) 2000, 2014, Oracle, Monty Program Ab and others.

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

MariaDB [(none)]> Ctrl-C -- exit!
Aborted
[root@localhost ~]#

Read Some More Articles

2 Comments

Leave a Reply

Your email address will not be published. Required fields are marked *

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