•  Home
  •  Dashboard
  •  Company
    • About Us
    • Blog
    • Careers
    • Contact Us
    • Data Centers
    • Looking Glass
    • Network
    • Reseller
  •  Hosting Services
    • Backup
    • Content Delivery Network
    • Colocation Hosting
    • Dedicated Hosting
    • DDoS Mitigation
    • IP Transit
    • Private Cloud
    • Wavelength
  •  Solutions
    • Ecommerce
    • Finance
    • Gaming
    • Hosting
    • Management
    • Security
    • System Integrator
  •  Support
    • Community
    • Knowledge Base
    • Open A Ticket
  •  USA & Canada: 800-933-1517
  •  International: 626-549-2801
  •  Email: sales@psychz.net
  • Services
    • Dedicated Servers
    • Colocation
    • Private Cloud
    • DDos Protection
    • IP Transit
    • CDN
    • Backup
  • Solutions
    • Ecommerce
    • Security
    • Gaming
    • Hosting
    • Management
    • Finance
    • System Integrator
  • Dashboard

Installing MariaDB on Centos 7

  • Home
  • Client
  • Knowledgebase
  • Linux
  • Centos 7
  • Installing MariaDB on Centos 7

Table Of Content

Related Articles

  • How to configure IP's On Centos 7?
  • How to install the GCC compiler in CentOS 7?
  • How to Install SSL Certificate On Centos 7
  • Linux Command Line Tutorial For Git
  • How To Install Git On Centos 7
  • Installation of Lamp Stack on CentOS 7
  • Yum Update Not Working on Centos 7
  • Views: (5343)
  • Votes: (2)
Was this article helpful?
VOTE

Installing MariaDB on Centos 7

Publisher: Psychz Networks,  March 18,2019

MariaDB is a community-developed, commercially supported fork of the MySQL relational database management system, intended to remain free and open-source software under the GNU GPL. Development is led by some of the original developers of MySQL, who forked it due to concerns over its acquisition by Oracle Corporation. It's designed as a replacement for MySQL, uses some commands that reference MySQL, and is the default package on CentOS 7.

In this tutorial, we will explain how to install the latest version of MariaDB on a CentOS 7 server. MariaDB is the preferred package and should work seamlessly in place of MySQL.

Step 1 — Installing MariaDB

We'll use Yum to install the MariaDB package, pressing y when prompted to confirm that we wish to proceed:

# yum install mariadb-server

Output:

================================================================================
Package                      Arch        Version               Repository          Size
================================================================================

Installing:
mariadb-server               x86_64      1:5.5.60-1.el7_5      base       11 M
Installing for dependencies:
mariadb                      x86_64      1:5.5.60-1.el7_5      base      8.9 M
perl-Compress-Raw-Bzip2      x86_64      2.061-3.el7           base       32 k
perl-Compress-Raw-Zlib       x86_64      1:2.061-4.el7         base       57 k
perl-DBD-MySQL               x86_64      4.023-6.el7           base      140 k
perl-DBI                     x86_64      1.627-4.el7           base      802 k
perl-Data-Dumper             x86_64      2.145-3.el7           base       47 k
perl-IO-Compress             noarch      2.061-2.el7           base      260 k
perl-Net-Daemon              noarch      0.48-5.el7            base       51 k
perl-PlRPC                   noarch      0.2020-14.el7         base       36 k
Transaction Summary
================================================================================
Installed:  mariadb-server.x86_64 1:5.5.60-1.el7_5                                                                                                            
Dependency Installed:
  mariadb.x86_64 1:5.5.60-1.el7_5              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-6.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               
Complete!

Now let us start the MariaDB database

systemctl start mariadb

systemctl doesn't display the outcome of all service management commands. Just to be sure we succeeded, we'll use the following command:

systemctl status mariadb

If MariaDB has successfully started, the output should contain "Active: active (running)`

● mariadb.service - MariaDB database server
  Loaded: loaded (/usr/lib/systemd/system/mariadb.service; disabled; vendor preset: disabled)
  Active: active (running) since Mon 2019-03-18 11:01:12 IST; 7s ago

Now we will create the necessary symlinks to ensure that MariaDB starts at boot, using the systemctl enable command.

# systemctl enable mariadb

Created symlink from /etc/systemd/system/multi-user.target.wants/mariadb.service to /usr/lib/systemd/system/mariadb.service.

Step 2 — Securing the MariaDB Server

MariaDB includes a security script to change some of the less secure default options for things like remote root logins and sample users. Use this command to run the security script:

 # mysql_secure_installation

The script provides a detailed explanation for every step. It first prompts for the root password, which in our case hasn't been set because we have freshly installed MariaDB so we'll press ENTER as it recommends. Next, we'll be prompted to set that root password, which we'll do.

Then, we'll accept all the security suggestions by pressing Y and then ENTER for the remaining prompts, which will remove anonymous users, disallow remote root login, remove the test database, and reload the privilege tables.

# mysql_secure_installation

The output is as following

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

 

Our MariaDB should be secure now. 

Step 3 : Create a New MariaDB Database

In the example below, we will create a demo database called "testdb"

First, we will log in to MariaDB

# mysql -u root -p

This will request you to enter the password. Once you enter the right password, it will prompt a welcome screen

Output:

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 2
Server version: 5.5.60-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.

 

Now, let us create a test database

MariaDB [(none)]> create database testdb;

Output

Query OK, 1 row affected (0.00 sec)

Here, "testdb" is the name of the database that we have created.

Step 4: Create a New user in MariaDB Database

MariaDB [(none)]> create user 'testuser' identified by 'password';

Here, the name of the user is "testuser" and the password assigned to it is "password"

Step 5: Granting permission to the user

Grant permissions to access and use the MariaDB server.

MariaDB [(none)]>  GRANT USAGE ON *.* TO 'testuser'@'123.123.123.123' IDENTIFIED BY 'mypassword';

The above command only allow access from a certain IP address (this is a very secure and common configuration)

Note: If you want to restrict access of a user to a specific database, you need to mention the DB name in place of '*.*'

MariaDB [(none)]>  GRANT USAGE ON `testdb`.* TO 'testuser'@'123.123.123.123' IDENTIFIED BY 'password';

To allow access to MariaDB server from any other computer on the network you can use '%' sign

MariaDB [(none)]> GRANT USAGE ON *.* TO 'testuser'@'%' IDENTIFIED BY 'password';


In this tutorial, we've installed and secured MariaDB on a CentOS 7 server and also learned how to create a database and a user in MariaDB.
If you find this tutorial useful, kindly vote us.

Hosting Services
  • Dedicated Hosting
  • Colocation Hosting
  • Backup
  • IP Transit
  • DDoS Mitigation
Support
  • Portal Login
  • Knowledgebase
  • Community
Company
  • About Us
  • Contact Us
  • Network
  • Data Centers
  • Looking Glass
  • Affiliates
  • Reseller
  • Blog
Policies
  • Privacy Policy
  • Acceptable Usage Policy
  • Terms and Conditions
  • Service Level Agreement
Company
  • Psychz Networks,
    A Profuse Solutions Company
    611 Wilshire Blvd #300
    Los Angeles,California 90017
    USA
  • US/Canada: 800-933-1517
  • International: 626-549-2801
Subscribe to Our Mailing List
* indicates required
Copyright © 2023 Psychz Networks, A Profuse Solutions Inc Company