Installing MariaDB Database Server on Ubuntu 18.04 LTS Server

e commerce 1606962 640

MariaDB database server is an open source server that is a fork of MySQL and a drop-in replacement. It is now the fastest growing open source database server today.

Over the many years, MySQL was the undisputed king of database servers for all of Linux systems. It only lost that title to MariaDB after MySQL current parent company, Oracle made some changes to its licensing terms that angered lots of people in the open source community. and that when MariaDB was borned.

Today, MariaDB is the default database server on the majority of Linux distributions, if not all.

For those who want to test MariaDB on Ubuntu 18.04 LTS , the steps below will get you started.

Step 1: Installing MariaDB Database Server

It takes a single command line to install MariaDB Database Server. to do that, run the commands below

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

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

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

After that, run the commands below to secure MariaDB server by creating the root user password and deleting the test database.

sudo mysql_secure_installation

When prompted, answer the questions below by following the guide.

  • Enter current password for root (enter for none): Just press the Enter
  • Set root password? [Y/n]: Y
  • New password: Enter password
  • Re-enter new password: Repeat password
  • 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

Restart MariaDB server when done.

sudo systemctl restart mariadb.service

Step 2: Configuring MariaDB Database Server

Now that MariaDB server is installed. the default configuration file is located at /etc/mysql/mariadb.config.d/50-server.cnf. this is where you enter config directives to optimize and enhance the database server performance. Most of the settings you’ll be looking for will be in this file.

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

Make all the changes you want in the file above and save. then restart the server.

sudo systemctl restart mariadb.service

That’s it! This is how to install MariaDB database server on Ubuntu 18.04 LTS


You may also like the post below:


  1. On some blogs, I see sudo service mysql start for starting mariadb server whereas on other sites I see the command as sudo systemctl start mariadb.service.

    I want to know what’s the difference and which works correctly on Ubuntu 18.04?

    1. systemctl is the new way to start and stop services (since Ubuntu 16). Then it depends of your Linux distribution and the packaging of your software. On Ubuntu 18, I think everything (including the “apache2ctl”) is replaced by “systemctl”. See for details.

  2. Thank You.It’s really helpful.

  3. This tutorial is great. I tried a couple of others, but stupid things like outdated location of the .cnf files just lead to frustration and wasted time. Thanks for doing it simple and doing it right.

Leave a Reply

Your email address will not be published.

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