Installing MariaDB on Ubuntu 18.04LTS
Last week we looked at how to install MySQL which is one of the original components of the LAMP stack (Linux, Apache, MySQL, PHP). This weeks it’s the turn of MariaDB.
As you’ll see if you compare last week’s post, the installation procedures are similar but not identical.
When Oracle purchased Sun and thereby MySQL, MariaDB was created as a new open source fork and many people migrated to it over time. As MariaDB is a drop in replacement for MySQL, this made the process very easy.
I have no issue with using MySQL or MariaDB, but I’m guessing if you’re here then you’re interested in MariaDB so read on.
It’s always a good start to ensure Ubuntu is up-to-date so before we begin let’s ensure our Ubuntu is in a good state.
> sudo apt update && sudo apt upgrade
Installing The Software
Before we can get things set up we need to install all the software. This is easily done by the following:
> sudo apt install mariadb-server mariadb-client
If you are not intending to run the applications that connect to the database on the same server you can omit the mariadb-client.
You will be shown all the associated packages (dependencies) that will be installed. It might seem like a lot but don’t worry – we’ll be needing them so confirm installation by typing [Y] and pressing the [ENTER] key.
Depending on your server and internet connection speed, this can take a while so sit back and relax.
When complete you’ll be returned to the command prompt.
Setting up MariaDB
The software is installed and ready to go but before we do anything else we really need to tighten up security as by default a blank password is provided which is a really really really bad idea.
And before you query the below command – yes – we type mysql ….. even though we are using MariaDB.
> sudo mysql_secure_installation
As your newly installed MariaDB has no password, just hit [ENTER].
We most certainly do want to set the root password. Type [Y] and hit [ENTER].
Type your password twice to ensure you’ve typed it in correctly, pressing [ENTER] after each password entry.
Unless you really have a good need for the default anonymous user, remove it by typing [Y] and then hitting [ENTER].
Allowing root access remotely is not the best idea, and it’s usually best to disallow it. Now let’s not confused here. This doesn’t mean you have to be at the server console to use root access. You can log into the server remotely and the use the MariaDB root access user. It simply means you can not connect directly do the database from a remote source using the root user.
So type [Y] and hit [ENTER].
MariaDB also installs itself with a test database. Again it’s best to remove this unless you really need it so type [Y] and hit [ENTER].
Finally you’ll be prompted to reload the privilege tables which is anoth4er good idea. So type [Y] and hit [ENTER].
So that’s it – MariaDB is now installed..