
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. In this guide, we will learn you how to install MariaDB on Ubuntu 18.04.
Install MariaDB on Ubuntu 18.04
There are two methods to install MariaDB on your Ubuntu 18.04 system:
- Install MariaDB from the Ubuntu repositories
- Install MariaDB from Official Repository
Generally, it is recommended to use the first method to install MariaDB.
Prerequisites
Before starting, make sure you are logged in to a Ubuntu 18.04 server with a non-root user with sudo privileges.
Installing MariaDB from Ubuntu Repositories
By default, MariaDB version 10.3 is included in the Ubuntu main repositories. At first, you need to update apt package manager index by typing:
sudo apt update
After that, install MariaDB by issuing the below command:
sudo apt install mariadb-server
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
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
Install MariaDB from Official Repository
The latest version of MariaDB 10.3 is available from the official MariaDB repository. At First, you need to download installer for MariaDB from MariaDB Repository page.
Now Import MariaDB GPG key to your system by typing command:
sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
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'
Next, you need to update package list:
sudo apt update
Now install MariaDB by executing below command:
sudo apt install mariadb-server
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
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
Securing MariaDB
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.
Login to MariaDB from the command line
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)]>
Conclusion
In this tutorial, We have given steps how to install MariaDB on Ubuntu 18.04 server. Also, you learned how to secure and connect to MariaDB server.
If you have any questions or suggestion, do not hesitate to comment out below comment box.
Leave a Reply