In this tutorial, we will show you how to install MariaDB on Ubuntu 20.04 LTS. For those of you who didn’t know, MariaDB is an open-source database management system, commonly used as an alternative for the MySQL portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. It is intended to be a drop-in replacement for MySQL.
This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘
sudo‘ to the commands to get root privileges. I will show you through the step-by-step installation of MariaDB in Ubuntu 20.04 LTS Focal Fossa.
Install MariaDB on Ubuntu 20.04 LTS Focal Fossa
Step 1. First, make sure that all your system packages are up-to-date by running the following
apt commands in the terminal.
sudo apt update sudo apt upgrade
Step 2. Installing MariaDB on Ubuntu 20.04.
Once the system is updated, use the following commands to install MariaDB Server on Ubuntu 20.04 (Focal Fossa):
sudo apt install software-properties-common mariadb-server mariadb-client
After the server is installed, the commands below can be used to stop, start and restart the database services:
sudo systemctl stop mariadb.service sudo systemctl start mariadb.service sudo systemctl restart mariadb.service
Let’s confirm our installation of the MariaDB server on Ubuntu 20.04:
Step 3. Securing MariaDB after installation.
By default, MariaDB is not hardened. You can secure MariaDB using the
mysql_secure_installation script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MariaDB:
Configure it like this:
- Set root password? [Y/n] y - Remove anonymous users? [Y/n] y - Disallow root login remotely? [Y/n] y - Remove test database and access to it? [Y/n] y - Reload privilege tables now? [Y/n] y
To log into MariaDB, use the following command (note that it’s the same command you would use to log into a MySQL database):
mysql -u root -p
Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing MariaDB in Ubuntu 20.04 LTS (Focal Fossa) system. For additional help or useful information, we recommend you to check the official MariaDB website.