How To Install MariaDB 10 on Ubuntu 18.04 / Ubuntu 16.04 / 14.04 & LinuxMint 18/17

3

MariaDB is a fork of the very popular MySQL database management system, and it is now considered as a full drop-in replacement for MySQL.

Install MariaDB 10 on Ubuntu 18.04 / Ubuntu 16.04 / 14.04 & LinuxMint 18

You can install MariaDB in two ways, using either Ubuntu repository or Official MariaDB mirror.

  1. Install MariaDB from Ubuntu Repository
  2. Install MariaDB from Official MariaDB mirror

Important Notes

Ubuntu 18.04 includes MariaDB 10.1 which the latest version for Ubuntu 18.04 in its main repository. So, we recommend using Ubuntu repository for MariaDB installation on Ubuntu 18.04

We recommend not to install MariaDB on Ubuntu 14.04 from Ubuntu repository as the version available in it is MariaDB 5.5.

Install MariaDB 10 from Ubuntu Repository

Installing from Ubuntu default repository is a straightforward way, but this may have bit old version of MariaDB.

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

Use mysql_secure_installation to secure the installation of MariaDB server.

sudo mysql_secure_installation

Perform the below steps only when you need to access MariaDB as MariaDB root user from external machines or other Unix logins, otherwise skip below.

Login as MariaDB root user.

$ sudo mysql -u root -p

OR

# mysql -u root -p
No password required
use mysql;
update user set plugin='mysql_native_password' where user='root';
flush privileges; 
quit;

Now you can log in as the MariaDB root user without any problem.

Install MariaDB 10 from Official Mirror

MariaDB offers an official installer package for MariaDB. You can choose any one of mirrors from the MariaDB downloads page to download it.

sudo apt-get -y install software-properties-common

Add public signing key to your system.

### Ubuntu 16.04 / LinuxMint 18 ###

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8

### Ubuntu 14.04 / LinuxMint 17 ###

sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xcbcb082a1bb943db

Use the add-apt-repository command to add MariaDB repository straight away.

### Ubuntu 16.04 / LinuxMint 18 ###

sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu xenial main'

### Ubuntu 14.04 / LinuxMint 17 ###

sudo add-apt-repository 'deb [arch=amd64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu trusty main'

OR

If you don’t wish to use the above command, you can manually create and update the MariaDB repository file under /etc/apt/sources.list.d/.

sudo nano /etc/apt/sources.list.d/mariadb.list

Place the following entries into the above file.

Ubuntu 16.04 / LinuxMint 18:

# http://downloads.mariadb.org/mariadb/repositories/
deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu xenial main
deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu xenial main

Ubuntu 14.04 / LinuxMint 17:

# http://downloads.mariadb.org/mariadb/repositories/
deb [arch=amd64,i386] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu trusty main
deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.2/ubuntu trusty main

Now, install MariaDB using the following command.

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

While installing MariaDB, the installer will prompt you to set the password for MySQL root user.

Access MariaDB

To access the MariaDB instance, run the following command on the terminal.

mysql -u root -p

Enter the password of root user that you have set during the installation.

Once after entering the password, you would get a MariaDB shell.

Install MariaDB 10 on Ubuntu 18.04 - MariaDB Shell
Install MariaDB 10 on Ubuntu 18.04 – MariaDB Shell

Control MariaDB service

In case if you want to start/stop the MariaDB, you can use the following command.

### Ubuntu 16.04 / LinuxMint 18 ###

sudo systemctl start mariadb
sudo systemctl stop mariadb

### Ubuntu 14.04 / LinuxMint 17 ###

sudo service mysql start
sudo service mysql stop

Run the following command in the terminal to check whether MariaDB is running.

### Ubuntu 16.04 / LinuxMint 18 ###

sudo systemctl status mariadb

### Ubuntu 14.04 / LinuxMint 17 ###

sudo service mysql status

That’s All.

Further Reading

You might also like

How To Install MariaDB 10 on Ubuntu 18.04 / Ubuntu 16.04 / 14.04 & LinuxMint 18/17

3