How To Install MariaDB on Ubuntu 20.04
In this article, we are going to see How to install MariaDB on Ubuntu 20.04 LTS Focal Fossa. MariaDB is the most powerful open source database server and widely used relational database management system.
MariaDB is forked from the popular database management system MySQL. It is intended to replaced MySQL as a default database server for most of the Linux Operating systems.
Install MariaDB on Ubuntu 20.04 #
Follow this instruction to install MariaDB server. You will need to run Ubuntu 20.04 operating systems.
Step 1 Update and Upgrade Packages
First, we always start our installations before we ensure our system is updated. Run the following command to update the APT list of available packages and their versions. Morover, use the upgrade command to actually install newer versions of the packages.
sudo apt update && sudo apt -y upgrade
Step 2 Installing MariaDB
At the time of writing this article, the latest MariaDB version 10.3 available in Ubuntu 20.04 default APT repositories.
sudo apt install software-properties-common mariadb-server mariadb-client
After the installation is completed, the MariaDB service will start automatically. Use the following command to verify that the database server is running.
systemctl status mariadb
You will see the output should show that the service is enabled and running:
● mariadb.service - MariaDB 10.3.22 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Sat 2020-05-23 10:32:09 IST; 9min ago Docs: man:mysqld(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 19446 (mysqld) Status: "Taking your SQL requests now..." Tasks: 30 (limit: 9349) Memory: 67.5M CGroup: /system.slice/mariadb.service └─19446 /usr/sbin/mysqld May 23 10:32:13 ubuntu /etc/mysql/debian-start: Processing databases May 23 10:32:13 ubuntu /etc/mysql/debian-start: information_schema May 23 10:32:13 ubuntu /etc/mysql/debian-start: mysql May 23 10:32:13 ubuntu /etc/mysql/debian-start: performance_schema May 23 10:32:13 ubuntu /etc/mysql/debian-start: Phase 6/7: Checking and upgrading tables May 23 10:32:13 ubuntu /etc/mysql/debian-start: Processing databases May 23 10:32:13 ubuntu /etc/mysql/debian-start: information_schema May 23 10:32:13 ubuntu /etc/mysql/debian-start: performance_schema May 23 10:32:13 ubuntu /etc/mysql/debian-start: Phase 7/7: Running 'FLUSH PRIVILEGES' May 23 10:32:13 ubuntu /etc/mysql/debian-start: OK
Step 3 Configuring MariaDB
You can interact with the MariaDB server from the command line. By default, you can access MySQL from the command line as a root user without prompt to provide a password.
Next, you have to run a security script to ensure our MariaDB server is secured and sets the root password. This script changes some of the less secure default options. It is recommended to run the following command.
$ sudo mysql_secure_installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! 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 authorisation. Set root password? [Y/n] y New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] y ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] y ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] y - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. 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!
Step 4 Check MariaDB Version
Run the following command to confirm our installation of the MariaDB server on Ubuntu 20.04.
$ mysql -V mysql Ver 15.1 Distrib 10.3.22-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Step 5 Create/Drop Database (Optional)
Finally, let’s create a test database.
$ sudo mysql -u root Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 58 Server version: 10.3.22-MariaDB-1ubuntu1 Ubuntu 20.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)]> CREATE DATABASE testdb; Query OK, 1 row affected (0.000 sec) MariaDB [(none)]> DROP DATABASE testdb; Query OK, 0 rows affected (0.001 sec) MariaDB [(none)]> QUIT Bye
We have guided you on how to install MariaDB on Ubuntu 20.04. After installation is completed, the database server service is up and running. Next, we have also run a security script to ensure our database is secured and set the root password.
We hope you have found this article helpful. Let us know your questions or feedback if any through the comment section in below. You can subscribe to our newsletter and get notified when we publish new articles for free. Moreover, you can explore here Ubuntu related articles.
If you like our article, please consider buying a coffee for us.
Thanks for your support!
Buy me a coffee!
Join the Discussion.