mariadb install linux

We can install the MariaDB server in ubuntu 18.04/20.04 in the same way. you can also configure the MariaDB installation on ubuntu to make it secure. In a similar way, we can install MariaDB in Linux as well.

MariaDB is an open-source relational database available for the Linux platform as well as windows. This is almost the same as the MySQL server. Let’s see, how to install MariaDB in Ubuntu 18.04/20.04.

If you want to install the MariaDB server in Centos, you can follow this article.

Check Out: Step To Install Mariadb 10 Database Server On CentOS 7

How To Install MariaDB Database Server on Ubuntu 20.04:

If you have MariaDB installed on the ubuntu machine, you need to remove it first to install the New version on ubuntu.

[email protected]:~$ sudo apt remove mariadb-server mariadb

Install MariaDB on Ubuntu using the below command.

ubun[email protected]:~$ sudo apt install mariadb-server mariadb

Once the installation is finished, we have to secure the MariaDB server using the below instructions.

Check Out: How To Update Windows Driver Using These Methods

The command to secure the MariaDB server on ubuntu is mysql_secure_installation.

[email protected]:~$ sudo mysql_secure_installation


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!

We’ll set the root password of the database, remove the test database, remove the anonymous users, disallow the remote login to the server.

Check Out: How To Change User Password In MySQL Server 5.x On CentOS

As you can log in to the server using the below command and see MariaDB 10.3 version is installed.

[email protected]:~$ sudo mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 55
Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.04

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)]>flush privileges;

We can also check the version using the below command as well as a “select version();”.

[email protected]:~$ sudo mysqladmin version
mysqladmin Ver 9.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu on x86_64
Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Server version 10.3.22-MariaDB-1ubuntu1
Protocol version 10
Connection Localhost via UNIX socket
UNIX socket /var/run/mysqld/mysqld.sock
Uptime: 9 min 36 sec

Threads: 7 Questions: 469 Slow queries: 0 Opens: 177 Flush tables: 1 Open tables: 31 Queries per second avg: 0.814

You can check the MariaDB service status using the below command.

[email protected]:~$ sudo systemctl status mariadb
● mariadb.service - MariaDB 10.3.22 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Active: active (running) since Tue 2020-06-16 05:20:33 PDT; 10min ago
Docs: man:mysqld(8)
Main PID: 3962 (mysqld)
Status: "Taking your SQL requests now..."
Tasks: 31 (limit: 2285)
Memory: 68.8M
CGroup: /system.slice/mariadb.service
└─3962 /usr/sbin/mysqld

Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: Processing databases
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: information_schema
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: mysql
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: performance_schema
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: Phase 6/7: Checking and upgrading tables
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: Processing databases
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: information_schema
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: performance_schema
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Jun 16 05:20:34 ubuntu /etc/mysql/debian-start[4025]: OK

Check Out: How To Create Security Group For Server On Amazon Web Service

Create a user and login with the same user:

you have to log in to the MariaDB server with sudo mysql -u root -p and we can create a user directly using the grant all command. This will create the user as well as permission on the database.

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]> grant all on *.* to 'use'@'%' identified by 'password' with grant option;
Query OK, 0 rows affected (0.000 sec)

MariaDB [mysql]> show grants for 'use'@'%';
| Grants for [email protected]% |
1 row in set (0.002 sec)

Use the below command to log in with the ‘use‘ user into the MariaDB server. 

[email protected]:~$ sudo mysql -u use -p

That’s it. mariadb install linux


Please enter your comment!
Please enter your name here