How to install MariaDB 10.2 in Ubuntu 16

SystemMen - This article will show you how to install MariaDB 10.2 in Ubuntu 16.04.

MariaDB supports repository for operating systems based Redhat and Debian .

Add MariaDB repository

MariaDB has a page, allowing you to choose the repository that fits your OS.

You can access this link to get the configuration for Ubuntu 16.04.

Or you can follow the instructions below.

You run the following command to install and verify the key for the repository.

root@ubuntu16:~# apt-get install software-properties-common apt-transport-https -y
root@ubuntu16:~# apt-key adv --recv-keys --keyserver hkp:// 0xF1656F24C74CD1D8

Then, run the following command to add MariaDB’s repository to the machine’s APT tree.

root@ubuntu16:~# add-apt-repository 'deb [arch=amd64,arm64,i386,ppc64el] xenial main'

Install MariaDB 10.2

After adding the repository, you run the command to update the packages.

root@ubuntu16:~# apt update -y

And then type the following command to install the MariaDB server.

root@ubuntu16:~# apt install mariadb-server -y

During installation, it will ask you to set a password for MariaDB’s root user.

Configuring mariadb-server-10.2

While not mandatory, it is highly recommended that you set a password for the MariaDB administrative "root" user.

If this field is left blank, the password will not be changed.

New password for the MariaDB "root" user:

You can set it now or later. You can also leave it blank.

The installation process may take several minutes.

how-to-install-mariadb-10-2-in-ubuntu-16 How to install MariaDB 10.2 in Ubuntu 16
Install MariaDB 10.2 in Ubuntu 16.04.

Enable and use mariadb

After the installation is completed, you can check the installed version with the following command.

root@ubuntu16:~# mysql -V
mysql Ver 15.1 Distrib 10.2.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2

Next, enable the mysql service.

root@ubuntu16:~# systemctl enable mysql

The results like this.

root@ubuntu16:~# systemctl enable mysql
mysql.service is not a native service, redirecting to systemd-sysv-install
Executing /lib/systemd/systemd-sysv-install enable mysql
insserv: warning: current start runlevel(s) (empty) of script `mysql' overrides LSB defaults (2 3 4 5).
insserv: warning: current stop runlevel(s) (0 1 2 3 4 5 6) of script `mysql' overrides LSB defaults (0 1 6).

And then start the service.

root@ubuntu16:~# systemctl start mysql

If you only allow access to local MariaDB, you don’t need to worry about firewalls.

If you want to allow remote access, you need to open port 3306 on the firewall.


Installing MariaDB on Ubuntu 16.04 is very easy. You just need to run a few lines of commands that are installed.

Installation is a story, using and optimizing MariaDB is another story.

«« »»