MariaDB is an open-source and multi-threaded database management system. It is replacement of MySQL and developed by some of the original developers of the MySQL.
Here at Ibmi Media, as part of our Server Management Services, we regularly help our Customers to perform related MariaDB queries on Ubuntu Linux System.
In this context, we shall look into how to install MariaDB on Ubuntu 18.04.
There are two methods to install MariaDB on your Ubuntu 18.04 system:
Generally, it is recommended to use the first method to install MariaDB.
To begin with this Installation procedure, ensure that you are using a non-root user with sudo privileges.
1. Install MariaDB from Ubuntu Repositories
By default, MariaDB version 10.3 is included in the Ubuntu main repositories.
i. Start by updating apt package manager index by typing:
$ sudo apt update
ii. After that, install MariaDB by issuing the below command:
$ sudo apt install mariadb-server
iii. MariaDB service will be start automatically. You can verify it by typing:
$ sudo systemctl status mariadb
Output
● mariadb.service - MariaDB database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset
Active: active (running) since Fri 2019-03-22 16:36:30 UTC; 48min ago
Main PID: 482 (mysqld)
Status: "Taking your SQL requests now…"
Tasks: 27 (limit: 4915)
CGroup: /system.slice/mariadb.service
482 /usr/sbin/mysqld
iv. Also, you can check MariaDB version by:
$ mysql -V
mysql Ver 15.1 Distrib 10.3.8-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
2. Install MariaDB from Official Repository
The latest version of MariaDB 10.3 is available from the official MariaDB repository.
Begin by downloading installer for MariaDB from MariaDB Repository page.
i. Now Import MariaDB GPG key to your system by typing command:
$ sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
ii. Once key is import is finished, add the MariaDB repository by:
$ sudo add-apt-repository 'deb [arch=amd64,arm64,ppc64el] http://ftp.utexas.edu/mariadb/repo/10.3/ubuntu bionic main'
iii. Next, you need to update package list:
$ sudo apt update
iv. Now install MariaDB by executing below command:
$ sudo apt install mariadb-server
v. The MariaDB service will be start automatically. You can verify it by below command:
$ sudo systemctl status mariadb
Output
● mariadb.service - MariaDB 10.3.8 database server
Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled)
Drop-In: /etc/systemd/system/mariadb.service.d
└─migrated-from-my.cnf-settings.conf
Active: active (running) since Sun 2018-07-29 19:36:30 UTC; 56s ago
Docs: man:mysqld(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 16417 (mysqld)
Status: "Taking your SQL requests now…"
Tasks: 31 (limit: 507)
CGroup: /system.slice/mariadb.service
└─16417 /usr/sbin/mysqld
vi. Check MariaDB version with:
$ mysql -V
mysql Ver 15.1 Distrib 10.3.8-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
MariaDB has a built-in script called mysql_secure_installation. To improve MariaDB installation security run the script:
$ sudo mysql_secure_installation
It will ask you to enter your root user password and also prompt to set new root password. Afterwards, it will prompt few more questions to remove anonymous users, test database and disable remote root logins. Press Y (yes) and hit Enter key for the all questions.
At last, script will reload the privilege tables to take effect immediately.
You can connect to MariaDB server as root user type below command:
$ mysql -u root -p
It will prompt you to enter the root password which you have previously set. After that, it will show output as following :
Welcome to the MariaDB monitor. Commands end with ; or \g.
Your MariaDB connection id is 12
Server version: 10.1.37-MariaDB-6 Ubuntu 18.04
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)]>
This article covers how to install MariaDB on Ubuntu 18.04 server. Also, you will learn how to secure and connect to MariaDB server. MariaDB is an open-source relational database management system, commonly used as an alternative for MySQL as the database portion of the popular LAMP (Linux, Apache, MySQL, PHP/Python/Perl) stack. Basically, It is intended to be a drop-in replacement for MySQL.
How to Install MariaDB ?
1. To install it, update the package index on your server with apt:
$ sudo apt update
2, Then install the package:
$ sudo apt install mariadb-server