How to install MariaDB 10.4 on Ubuntu 18.04 LTS

As we all know MariaDB is an open source and relational database management system based on MySQL technology and we can say it is a great replacement of MySQL Database. MariaDB is developed by original developers of MySQL after concerns raised by Oracle’s acquisition of MySQL. This post describes how to install the MariaDB on Ubuntu 18.04 LTS.

Also Read: How to install MariaDB 10.4 on CentOS & RHEL8/7 & Debian 10 (Buster) Linux.
Also Read: Installation of Ubuntu 18.04 LTS Linux.

Installing MariaDB

Step-1: Importing MariaDB key & repository

$ sudo apt-get install software-properties-common

Step-2: Import keys on system
$ sudo apt-key adv –fetch-keys ‘’

Step-3: Import MariaDB repository
$ sudo add-apt-repository ‘deb [arch=amd64,arm64,ppc64el] bionic main’

Step-4: After importing and adding a key and the repository in the system, update and install MariaDB 10.04 from the MariaDB repository with below command. Update the system with below command.
$ sudo apt update
Step-5: Following command install MariaDB
$ sudo apt install mariadb-server

Step-6: Restart, Enable and Verify the MariaDB Service Status
$ sudo systemctl status mariadb
$ sudo systemctl restart mariadb
$ sudo systemctl enable mariadb

Step-7: Improving MariaDB Security
This scripts enables the following security.
  1. Setting a password for root accounts.
  2. Removing anonymous user.
  3. Disable root login remotely.
  4. Removing test database.

# mysql_secure_installation

Step-8: MariaDB Configuration File Location.
Now MariaDB server is installed, the default config file is located on /etc/mysql/mariadb.cnf
Step-9: Login into MariaDB 
To login into the MariaDB server, execute below command from the Ubuntu console with password which was set earlier. Type “Exit” command to come out from the console.

$ sudo mysql -u root -p
Step-10: How to Check MariaDB Version.
Below command to check Installed MariaDB Version.
$ sudo mysql –version

Steps to change MariaDB default port.

Follow below steps to change MariaDB default port. MariaDB default port is 3306. Changing a default port of MariaDB is one of the step to secure the database.
Step-1: Open configuration File. Add desire port just below [mysqld] directive as shown below screenshot. Save and Exit from file.
$ vi /etc/mysql/mariadb.cnf

Step-2: Restart MariaDB Service and check listening port with below command.
$ sudo systemctl restart mariadb
sudo ss -antp | grep 6033

Conclusion: In this tutorial, we have seen Installation of MariaDB 10.4 on Ubuntu 18.04 LTS. Big thanks for reading all the way to the end. Please share it with Your Friends & Help Someone… and also Like Our Facebook Page. Let me hear your thoughts in the comments below!

Leave a Comment