Here is how you can install MariaDB on Ubuntu. In particular on Vultr’s instance i.e. Ubuntu 16.04 / 18.10 and 18.04 LTS.

Prerequisites

  • Have an Ubuntu 16.04 x64 / 18.01 x64 / 18.10 x64 instance.
  • Logged in as a root with sudo privileges.

To get started with the installation of MariaDB, follow the steps below:

Install MariaDB on Ubuntu

To install MariaDB server, run the following commands:

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

After installing MariaDB, you can check the MariaDB status by using the following command:

sudo systemctl status mariadb

Output

mariadb.service - MariaDB database server
   Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
   Active: active (running) since Fri 2019-04-19 19:11:25 UTC; 1 day 13h ago
 Main PID: 638 (mysqld)
   Status: "Taking your SQL requests now..."
    Tasks: 28 (limit: 502)
   Memory: 80.3M
   CGroup: /system.slice/mariadb.service
           └─638 /usr/sbin/mysqld

You can check the MariaDB version with the following command:

mariadb -V

You can stop, start and enable the MariaDB when Ubuntu is rebooted with the following commands:

sudo systemctl stop mariadb.service
sudo systemctl start mariadb.service
sudo systemctl enable mariadb.service
Now use mysql_secure_installation to secure the installation of MariaDB server i.e.
sudo mysql_secure_installation

The script will prompt you to determine which actions to perform by answering the following questions.

In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and you haven't set the root password yet, the password will be blank, so you should just press enter here.

Enter current password for root (enter for none):
OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MariaDB root user without the proper authorization.

You already have a root password set, so you can safely answer 'n'.
Change the root password? [Y/n] n
... skipping.

Remove anonymous users? [Y/n] Y
... Success!

Disallow root login remotely? [Y/n] y
... Success!

Remove test database and access to it? [Y/n] y
- Dropping test database...
... Success!
- Removing privileges on test database...
... Success!

Reload privilege tables now? [Y/n] y
... Success!
Cleaning up...

All done! If you've completed all of the above steps, your MariaDB installation should now be secure.

Thanks for using MariaDB!

Now that MariaDB is installed, to verify whether the database server was successfully installed, run the following commands

sudo mysql -u root -p

type the root password when prompted…

Welcome to the MariaDB monitor.  Commands end with ; or \g.
Your MariaDB connection id is 190
Server version: 10.1.29-MariaDB-6ubuntu2 Ubuntu 18.10

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

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

MariaDB [(none)]>

If you see a similar message as shown above, then the MariaDB was successfully installed…

Conclusion

Now you have learned how to Install MariaDB server on Ubuntu and you also know how to connect to the MariaDB server from the command line.

If you have questions feel free to leave a comment below.

Leave your Comment