(Last Updated On: August 12, 2019)

How do I install MariaDB 10.4 on Ubuntu 18.04 / Ubuntu 16.04?. Can I install MariaDB 10.4 on Ubuntu 18.04 / Ubuntu 16.04 from APT repository?. MariaDB is a drop-in replacement of MySQL with more features, new storage engines, and better performance. You can read more on MariaDB 10.4 features from the official website.

For CentOS 7, check: How to Install MariaDB 10.4 on CentOS 7

For Debian 9 / Debian 8: How to Install MariaDB 10.4 on Debian 9 / Debian 8

Install MariaDB 10.4 on Ubuntu 18.04 / Ubuntu 16.04

To install MariaDB 10.3 on Ubuntu 18.04 / Ubuntu 16.04, you need to add MariaDB repository on to the system.

Step 1: Install software-properties-common if missing:

sudo apt-get install software-properties-common

Step 2: Import MariaDB gpg key:

Run the command below to add Repository Key to the system

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

Step 3: Add the apt repository

Once the PGP key is imported, proceed to add repository URL:

sudo add-apt-repository "deb [arch=amd64,arm64,ppc64el] http://mariadb.mirror.liquidtelecom.com/repo/10.4/ubuntu $(lsb_release -cs) main"

If you don’t have add-apt-repository present in your system. check  How to Install add-apt-repository on Debian 9 / Ubuntu 18.04/16.04

Step 4: Install MariaDB Server on Ubuntu 18.04 / Ubuntu 16.04

The last step is the installation of MariaDB Server:

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

You will be prompted to provide MariaDB root password, type the password to set.

Confirm password:

Press <Ok> to confirm the new password and install MariaDB. Make sure you memorize or keep provided password on your favorite password manager.

The service should be started automatically after installation.

$ sudo systemctl status mysql
* mariadb.service - MariaDB 10.4.1 database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
  Drop-In: /etc/systemd/system/mariadb.service.d
   Active: active (running) since Tue 2018-12-25 08:26:18 PST; 24min ago
     Docs: man:mysqld(8)
 Main PID: 7564 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 32 (limit: 1110)
   CGroup: /system.slice/mariadb.service
           `-7564 /usr/sbin/mysqld

Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: Running 'mysqlcheck' with connection arguments: --port='3306' --socket='/var/run/mysqld/mysqld
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: # Connecting to localhost...
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: # Disconnecting from localhost...
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: Processing databases
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: information_schema
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: performance_schema
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: Phase 7/7: Running 'FLUSH PRIVILEGES'
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7604]: OK
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7706]: Checking for insecure root accounts.
Dec 25 08:26:23 ubuntu-01 /etc/mysql/debian-start[7710]: Triggering myisam-recover for all MyISAM tables and aria-recover for all Aria tables

Test login to MariaDB shell using mysql command:

$ mysql -u root -p
Enter password: 
Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 47
Server version: 10.4.1-MariaDB-1:10.4.1+maria~bionic-log mariadb.org binary distribution

Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others.

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
MariaDB [(none)]>

Check version using the command:

MariaDB [(none)]> SELECT VERSION();
| VERSION()                                |
| 10.4.1-MariaDB-1:10.4.1+maria~bionic-log |
1 row in set (0.001 sec)

MariaDB [(none)]> QUIT

Step 5: Install Desktop Database Management Tool

If working with MySQL command line is not your thing, then consider installing a Database Tool to help you. Check out our guide below:

Install and Configure DBeaver on Ubuntu 18.04 / Ubuntu 16.04 / Debian 9

That’s all. Enjoy using MariaDB 10.4 on Ubuntu 18.04 / Ubuntu 16.04.

Best MySQL Study books:

  • Getting Started With SQL – A Hands-On Approach for Beginners – a simple, to-the-point introductory read that’ll touch on the practical implications of SQL. Here, a reader gets introduced concisely to all the basics of the language;
  • Head First SQL – Your Brain on SQL – A Learner’s Guide;
  • SQL Cookbook: Query Solutions and Database Techniques for Database Developers – a book is full of hacks and tips that can be applied in day-to-day database management;
  • Teach Yourself MS SQL Server – a fairly old book, yet, it covers all the aspects of SQL Server on a high level;
  • Effective SQL – an easy-to-read guide book that explores SQL features. Keep in mind that you might need some SQL knowledge to apply the ideas that have been laid out.

More Learning:

Best Kubernetes Study books

Best LPIC-1 and LPIC-2 certification study books

Best CCNA Security (210-260) Certification Study Books

Best Linux Books for Beginners & Experts