In this tutorial we’ll learn how to install MariaDB on Ubuntu 16.04. We will also install and configure its prerequisites. MariaDB is a drop-in replacement for MySQL. It is developed by former members of MySQL team who concerned that Oracle might turn MySQL into a closed-source product. Many Linux distributions and companies have migrated to MariaDB.
I recommend to use a minimal Ubuntu server setup as a basis for the tutorial, that can be a virtual or a root server image with an Ubuntu 16.04 minimal install from a web hosting company or you use our minimal server tutorial to install a server from scratch.
Install MariaDB on Ubuntu 16.04
Step 1. First, ensure your system and apt package lists are fully up-to-date by running the following:
apt-get update -y && apt-get upgrade -y
Step 2. Installing MariaDB on Ubuntu 16.04.
Installing from Ubuntu default repository is a straightforward way, but this may have bit old version of MariaDB:
apt-get install mariadb-server mariadb-client
After it’s installed, MariaDB server should be automatically started. Use systemctl to check its status:
systemctl status mysql
With MariaDB installed, we must now turn to security. The next step will perform some basic hardening on the newly-installed database server:
Follow the prompts as below:
- Would you like to setup VALIDATE PASSWORD plugin? press Enter here for No
- Please set the password for root here. New password: Type a secure password here then press Enter
- Re-enter new password: Re-type the secure password here then press Enter
- Remove anonymous users? (Press y|Y for Yes, any other key for No) : press y and then Enter here
- Disallow root login remotely? (Press y|Y for Yes, any other key for No) : press y and then Enter here
- Remove test database and access to it? (Press y|Y for Yes, any other key for No) : press y and then Enter here
- Reload privilege tables now? (Press y|Y for Yes, any other key for No) : press y and then Enter here
Once the database server is secured, check it’s installed version and login to the MariaDB command shell as follows:
To access the MariaDB instance, run the following command on the terminal.
mysql -u root -p
Congratulation’s! You have successfully configured MariaDB on your Ubuntu 16.04 LTS server.