How to Install MariaDB 10.4 on Ubuntu 18.04, Ubuntu 20.04

This tutorial will be showing you how to install MariaDB 10.4 on Ubuntu 18.04 and Ubuntu 20.04 server. MariaDB is a mature, stable, open-source relational database forked from MySQL. Most Linux distributions have replaced MySQL with MariaDB as the default database server. MariaDB powers applications at companies and organizations including Google, Wikipedia, Tencent, Verizon, Deutsche Bank, Huatai Securities and more.

At the time of this writing, the latest stable version is MariaDB 10.4.8, released on September 11, 2019. Notable changes includes:

  • The unix_socket authentication plugin is now default on Unix-like platforms.
  • mysql.user table is retired. User accounts and global privileges are now stored in the mysql.global_priv table.
  • The obsolete table is no longer created.
  • Galera has been upgraded from Galera 3 to Galera 4.
  • And more.

Every major MariaDB release will be maintained at least 5 years. MariaDB 10.4 will be supported until June, 2024.

Install MariaDB 10.4 on Ubuntu 18.04, 20.04 From Official Repository

The default Ubuntu repository includes MariaDB package, but the version is out of date. Ubuntu 18.04 contains only MariaDB 10.1 and Ubuntu 20.04 contains MariaDB 10.3. We can install the latest version from the official MariaDB repository.

Visit and select your Linux distribution, release, version, and the repository mirror that you would like to use. For example, I selected Ubuntu 18.04, MariaDB 10.4 and the Limestone Networks mirror, as shown in the following screenshot.

mariadb ubuntu 18.04 lts repository

Once all of the choices have been made, customized instructions will appear at the bottom of the page. As an example, I need to run the following commands to add the repository on Ubuntu 18.04.

sudo apt-get install software-properties-common

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

sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] bionic main'

To add the repository on Ubuntu 20.04, simply replace bionic with focal in the third command.

Then update package index and install MariaDB server.

sudo apt update

sudo apt install mariadb-server

The galera-4 package will be installed automatically with the MariaDB server. Once the installation finishes, MariaDB server automatically starts. You can check its status with:

systemctl status mysql


systemctl status mariadb

As you can see, it’s active and running.

mariadb status

Hint: Press Q to gain back control of the terminal if the above command doesn’t quit immediately.

If it’s not running, you can manually start it with:

sudo systemctl start mariadb

To enable auto start at boot time, run

sudo systemctl enable mariadb

To log in to MariaDB monitor, run

sudo mysql -u root


sudo mariadb -u root

If you are asked to enter a password, you need to enter the password for your user’s sudo password, not the MariaDB root user password.

mariadb 10.4 unix_socket plugin

We can see that the server version is 10.4.8, installed from binary distribution. To log out, run


Run the Post Installation Script

To secure MariaDB server as much as possible, run the post installation script.

sudo mysql_secure_installation

MariaDB 10.04 uses unix_socket authentication plugin, so the MariaDB root user doesn’t need a password. When the script asks you to enter the password for root, just press Enter.  Answer “n” to the next two questions.

mariadb 10.4 ubuntu 18.04

Then you can press Enter to answer all remaining questions, which will remove anonymous user, disable remote root login and remove test database. This step is a basic requirement for MariaDB database security. (Notice that Y is capitalized, which means it is the default answer. )

mariadb ubuntu 18.10

InnoDB vs XtraDB Storage Engine

By default, until MariaDB 10.1, MariaDB uses the XtraDB storage engine, a performance enhanced fork of the InnoDB storage engine from MySQL. However, over time, MySQL has implemented almost all of the improvements. InnoDB has caught up, so from MariaDB 10.2, InnoDB is the default engine.

To check which is the default storage engine, log into MariaDB monitor and run the following command.

show engines;

On MariaDB 10.1, the above command returns the following result, which indicates XtraDB is the default engine.

XtraDB storage engine

On MariaDB 10.2, 10.3 and 10.4, the above command returns the following result, which indicates InnoDB is the default engine.

InnoDB storage engine


Note: This troubleshoot tip no longer applies to MariaDB 10.4, which now uses unix_socket authentication plugin by default. However, you might find it useful if you are still using MariaDB 10.3.

If you previously installed MariaDB from the default Ubuntu repository and now you install the latest MariaDB from, then you will probably encounter the following error when trying to login.

ERROR 1524 (HY000): Plugin 'unix_socket' is not loaded

This is because the binary still uses the mysql_native_password plugin to authenticate user login, whereas the MariaDB binary from Ubuntu repository uses the unix_socket plugin to authenticate user login. The former requires user to enter password, whereas the latter allows user to run the following command to login, without having to provide MariaDB root password.

sudo mysql -u root

Originally MariaDB root user is set to use the unix_socket to login because it’s installed from Ubuntu repository, but now you install a new binary from, which disables the unix_socket plugin, so you will see the above error.

If you would like to continue to use the unix_socket method, then edit the 50-server.cnf file.

sudo nano /etc/mysql/mariadb.conf.d/50-server.cnf

Add the following line in the [mariadb] unit at the bottom.

plugin_load_add = auth_socket

Save and close the file. Then restart MariaDB server for the change to take effect.

sudo systemctl restart mariadb

If you prefer to use the mysql_native_password method, please see the following article.

There are two other differences worth mentioning.

  1. The MariaDB package from Ubuntu repository uses the /etc/mysql/mariadb.conf.d/50-server.conf file for server configuration, whereas the MariaDB package from repository uses the /etc/mysql/my.cnf file for server configuration on clean install.
  2. The MariaDB package from repository will create a debian-sys-maint user in the database, whereas the MariaDB packages from Ubuntu repository won’t create this user. The password for this user is stored in /etc/mysql/debian.cnf file.

If you see the following error while running the sudo systemctl status mariadb command.

ERROR 1045 (28000): Access denied for user 'debian-sys-maint'@'localhost' (using password: YES)

You may need to reconfigure the mariadb-server-10.3 package with the following command.

sudo dpkg-reconfigure mariadb-server-10.3

When the reconfigure wizard asks you to enter a new root password, you can just press the Tab key and press Enter, so the root password won’t be changed.


That’s it. I hope this article helped you install the latest version of MariaDB on Ubuntu 18.04 and Ubuntu 18.04. As always, if you found this post useful, then subscribe to our free newsletter to get more tips and tricks. Take care 🙂

Rate this tutorial
[Total: 7 Average: 5]

7 Responses to “How to Install MariaDB 10.4 on Ubuntu 18.04, Ubuntu 20.04

  • Well done!

  • Lambin_Nock
    5 years ago

    Thank you! Very helpful setting up MariaDB on my Nginx server!!!

  • Hello there,
    Similarly to this “Install Latest MariaDB Version on Ubuntu 18.04, Ubuntu 19.04” do you have it for “PHP latest version” ?
    Kindest Regards,

  • Can’t upgrade mariadb-server:

    $ sudo apt upgrade mariadb-server
    Reading package lists... Done
    Building dependency tree
    Reading state information... Done
    Calculating upgrade... Done
    Some packages could not be installed. This may mean that you have
    requested an impossible situation or if you are using the unstable
    distribution that some required packages have not yet been created
    or been moved out of Incoming.
    The following information may help to resolve the situation:
    The following packages have unmet dependencies:
     mariadb-server : Depends: mariadb-server-10.4 (>= 1:10.4.14+maria~bionic) but it is not going to be installed
    E: Broken packages

Leave a Comment

  • Comments with links are moderated by admin before published.
  • Your email address will not be published.
  • Use <pre> ... </pre> HTML tag to quote the output from your terminal/console.
  • Please use the community ( for questions unrelated to this article.
  • I don't have time to answer every question. Making a donation would incentivize me to spend more time answering questions.

The maximum upload file size: 2 MB. You can upload: image. Links to YouTube, Facebook, Twitter and other services inserted in the comment text will be automatically embedded. Drop file here