How to Install MariaDB Latest on Ubuntu

Want to install MariaDB on Ubuntu 17.04 | 17.10? This brief tutorial is going to show you the steps to get it done.

MariaDB is a drop-in replacement for MySQL. This means, if you rip out MySQL and install MariaDB, applications and services that depended on MySQL will still function. These application won’t know the difference.

To get MariaDB on Ubuntu, all one has to do is run the commands below:

sudo apt-get update
sudo apt-get install mariadb-server mariadb-client

The commands above will install the latest stable version of MariaDB in Ubuntu default repositories.

However, if you want to install the absolute latest of MariaDB, you may have to add its repositories to your system. To do that, run the commands below to add its repository key to Ubuntu

sudo apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8

Then run the commands below to add MariaDB version repository to your Ubuntu machine. Take notes of the highlighted version number ( 10.2 )in the line code below. Replace the version number appropriately. So, if the latest version number is 11.1, you replace 10.1 with it.

sudo sh -c "echo 'deb '$(lsb_release -cs)' main' > /etc/apt/sources.list.d/MariaDB.list"

After adding the repository, run the commands below to update and install the server

sudo apt-get update
sudo apt-get install mariadb-server mariadb-client

When you’re done installing the database server above, run the commands below to secure it with a root password.

sudo mysql_secure_installation

You’ll get prompted to answer the below questions.. use this guide below to answer.

Enter current password for root (enter for none): PRESS ENTER

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

After installing MariaDB, the commands below can be used to stop, start and enable the service to always startup when the server boots up

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service

Congratulations! You’ve successfully installed MariaDB on Ubuntu 17.04 | 17.10.

You may also like the post below:

5 Replies to “How to Install MariaDB Latest on Ubuntu”

  1. Hi and thank you for the tutorial, but it does not too well with me. I have a new installation of Kubuntu 17.04 and this is the problem I face.

    #sudo systemctl enable mysql
    Synchronizing state of mysql.service with SysV service script with /lib/systemd/systemd-sysv-install.
    Executing: /lib/systemd/systemd-sysv-install enable mysql
    Failed to enable unit: Refusing to operate on linked unit file mysql.service

  2. Just run the following command manually: /lib/systemd/systemd-sysv-install enable mysql
    and it should work, well it worked with me. I don’t know why the same command run by the systemd doesn’t work and I didn’t dare looking any deeper. God luck. Michel

  3. “Just run the following command manually: /lib/systemd/systemd-sysv-install enable mysql”
    No, it doesn’t:
    The command is : sudo /lib/systemd/systemd-sysv-install enable mysql
    This is computing, not a cooking class. Give proper instructions.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.