How to install MariaDB 10.3 using Ubuntu 16.04

MariaDB is an free and opensource relational database server which is the most popular database servers, Developed by MariaDB Corporation AB, MariaDB Foundation and Written in C, C++, Perl, Bash.

Step 1: Adding MariaDB Repo

MariaDB 10.3 installation You need to add the repo and key by following the commands with root privileges.

sudo -i
apt-get install software-properties-common dirmngr -y
apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8
add-apt-repository 'deb [arch=amd64] xenial main'

Step 2: Update the ubuntu repo

After this you need to update the ubuntu repo by using the given commands.

apt-get update

Step 3: Installing MariaDB

Now We are ready to install MariaDB in ubuntu machine by following the commands.

apt-get install mariadb-client mariadb-server -y

Note :- While installing MariaDB packages You should get the MariaDB administrative password to set do not miss that change and set your  strong password here.

By default MariaDB service gets running status and its work will be port 3306, To change and bind with IP address and reconfigure the MariaDB port number You need to add the param in my.cnf which is located in default location  /etc/mysql/my.cnf and then restart the MariaDB service after save your own param in my.cnf.

Step 4: Controlling the MariaDB services

To get status of MariaDB, You need to use following commands.

systemctl status mysql

You should get output like this :-

● mariadb.service – MariaDB 10.3.21 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: 
  Drop-In: /etc/systemd/system/mariadb.service.d
   Active: active (running) since Tue 2019-12-17 13:10:42 IST; 55s ago
     Docs: man:mysqld(8)
 Main PID: 9125 (mysqld)
   Status: “Taking your SQL requests now…”
   CGroup: /system.slice/mariadb.service
           └─9125 /usr/sbin/mysqld
Dec 17 13:10:42 client systemd[1]: Started MariaDB 10.3.21 database server.

To stop the MariaDB service use the following the commands.

systemctl stop mysql

To restart the MariaDB service use the following the commands.

systemctl restart mysql

To start  the MariaDB service on boot time use the following the commands.

systemctl enable mysql

To disable on boot time the MariaDB service use the following the commands.

systemctl disable mysql

Step 5: Securing MariaDB

By default MariaDB installation We have got some test database and its allow from remotely access, To protect the MariaDB, We need to executive the script and follow the steps.



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.

You already have a root password set, so you can safely answer ‘n’.

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

Step 6: Accessing the MariaDB

To login in MariaDB shell you need to use following the commands.

mysql -u root -p

Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or g.
Your MariaDB connection id is 22
Server version: 10.3.21-MariaDB-1:10.3.21+maria~xenial binary distribution

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

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

MariaDB [(none)]> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
3 rows in set (0.038 sec)

MariaDB [(none)]> 

Now we can see the MariaDB some schema’s, Here the MariaDB installation setup is completed.

How to install MariaDB 10.3 using Ubuntu 16.04

Leave a Reply

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

Scroll to top