MariaDB ia an enhanced, drop-in replacement for MySQL. MariaDB can be a better choice for choice for database professionals looking for a robust, scalable, and reliable SQL server. MariaDB has a number of updated features over MySQL. Use below links to read features comparison between MariaDB and MySQL
This article will help you to Install MariaDB in Ubuntu 18.04 and 16.04 LTS and Other Systems using the Apt package manager, For older versions use the Apt-get command.
Step 1 – Backup Databases
MariaDB 10.2 has been released with various upgrades and configuration changes than previous releases. So, If you have already run an older MariaDB version, It’s recommended to take all databases backups before upgrading.
You can back up all your databases using the below single command.
mysqldump -u root -p --all-databases > all-db.sql
Step 2 – Add Apt Repository
You can find the MariaDB Apt configuration file from the official website. Import the package singin key for MaraiDB packages on your system.
sudo apt install software-properties-common sudo apt-key adv --recv-keys --keyserver hkp://keyserver.ubuntu.com:80 0xF1656F24C74CD1D8
After this, create a new Apt configuration file for MariaDB with the following command. You can use any text editor than vim.
sudo vim /etc/apt/sources.list.d/mariadb.list
And add the following values to the configuration file as per your Ubuntu version. To check your Ubuntu system version run ‘lsb-release -a’ command.
For Ubuntu 18.04 “Bionic”
deb [arch=amd64,arm64,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu bionic main deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu bionic main
For Ubuntu 16.04 “Xenial”
deb [arch=amd64,arm64,i386,ppc64el] http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu xenial main deb-src http://nyc2.mirrors.digitalocean.com/mariadb/repo/10.4/ubuntu xenial main
For Other Ubuntu Versions
For other versions of Ubuntu. Click here to find suitable repository for your system.
Step 3 – Install MariaDB in Ubuntu
After adding the repository to your system and use the following commands to install MariaDB-server on your Ubuntu system. This will remove any previous version of MariaDB packages and install the latest packages on the system. Make sure you have proper backups of databases before running the below commands.
sudo apt update sudo apt install mariadb-server
While installing MariaDB using the above command installer will prompt for the MariaDB root account password twice like the below snapshot.
Step 4 – Login To MariaDB
After completing installation you can connect to MariaDB using following command. When prompted, use the password entered during installation of MariaDB.
mysql -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 8 Server version: 10.2.6-MariaDB-10.2.6+maria~xenial mariadb.org binary distribution 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)]>
Step 5 – Manage MariaDB Service
Some times we need to stop or start MariaDB service. Use the following commands to stop, start, check status and restart MariaDB servic.
sudo systemctl stop mysql.service # To Stop MariaDB service sudo systemctl start mysql.service # To Start MariaDB service sudo systemctl status mysql.service # To Check MariaDB service status sudo systemctl restart mysql.service # To Stop then Start MariaDB service