This brief tutorial shows students and new users how to install the latest version of MariaDB on Ubuntu servers.
As we said earlier, MariaDB is a drop in replacement for MySQL. It’s practically MySQL with a different name.
MariaDB comes in Ubuntu default repository. However, the version in the repository is a stable tested version and not the latest. To install MariaDB on Ubuntu, all one has to do is run the installation command.
However, if you wish to install the latest stable version that’s not already in Ubuntu repository, you will have to add MariaDB repository to Ubuntu and this brief tutorial is going to show you how to do just that.
The post below shows you how to install MariaDB from Ubuntu repository.
Step 1: Adding MariaDB repository on Ubuntu
To add MariaDB repository on Ubuntu systems, follow the steps below. First, make sure software-properties-common package is installed. Just in case it’s not, run the commands below.
sudo apt-get install software-properties-common
Next, run the commands below to import MariaDB public key used by the package management system.
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
Finally, run the commands below to add MariaDB repository to your Ubuntu machine.
sudo sh -c "echo 'deb https://mirrors.evowise.com/mariadb/repo/10.1/ubuntu '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/MariaDB.list"
The above commands add MariaDB 10.1 repository to Ubuntu with the latest packages. Remember to change the highlighted version number to the current latest.
At the time of this writing the latest current version was 10.1. The latest alpha version was 10.2
Step 2: Installing MariaDB latest on Ubuntu
Now that the MariaDB 10.1 repository has been added to Ubuntu, run the guides below to install the current version.
First, run the commands below to update your Ubuntu machines.
sudo apt-get update
Next, run the commands below to install MariaDB server and client.
sudo apt-get install mariadb-server mariadb-client
Doing the installation, you may be prompted to to create a new password for MariaDB root user.
Please enter and confirm a password. You’ll need this password to manage the database server.
After that, MariaDB will be fully installed on your machine.
To secure MariaDB database server, run the commands below:
When you run the above command, you’ll be prompted to create a root password, remove anonymous users, disable remote root access and delete the test database.
Follow this guide below in answering the questions:
- Enter current password for root (enter for none): Enter current password.
- Change root password? N
- Remove anonymous users? Y
- Disallow root login remotely? Y
- Remove test database and access to it? Y
- Reload privilege tables now? Y
When you’re done, restart MariaDB and you’re done.
To verify MariaDB version, run the command below