How to Install MariaDB on Ubuntu 22.04. MariaDB is one of the most widely used database software built over MySQL and used for several well-known applications that utilize like WordPress and many more.
In this guide you are going to learn how to install latest MariaDB community server on Ubuntu 22.04
This setup is tested on Google cloud, so it will work on all cloud hosting services like AWS, Azure or any VPS or any dedicated servers running Ubuntu 22.04.
- Root access to your server or a sudo user.
Step 1: Setup Initialization
Start by updating the packages to the latest version available using the following command.
sudo apt update sudo apt upgrade
Once you have updated the setup you can start the setup.
Step 2: Install MariaDB
By default Ubuntu 22.04 repositories have the MariaDB version 10.6 package. So you can install it directly
sudo apt install mariadb-server mariadb-client
Once the installation is completed, the MariaDB service will start automatically. To verify that the MariaDB server is running, type:
sudo service mariadb status
The output should show that the service is enabled and running:
● mariadb.service - MariaDB 10.6.7 database server Loaded: loaded (/lib/systemd/system/mariadb.service; enabled; vendor preset: enabled) Active: active (running) since Thu 2022-05-12 16:49:10 UTC; 9h ago Docs: man:mariadbd(8) https://mariadb.com/kb/en/library/systemd/ Main PID: 1632 (mariadbd) Status: "Taking your SQL requests now..." Tasks: 7 (limit: 1146) Memory: 261.7M CPU: 1min 41.373s CGroup: /system.slice/mariadb.service └─1632 /usr/sbin/mariadbd
Now you have installed the latest version of MariaDB server.
Step 3: Secure MariaDB
MariaDB installation comes with a script named
mysql_secure_installation that allows you to easily improve the MariaDB server security.
You will be prompted to switch authentication type.
Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n]
It would be better to enter n to use the default authentication method. If this is switched it can be sufficient for some greater security and usability in many cases, but it also complicated things when you needed to allow administrative rights for external programs (e.g., phpMyAdmin).
On the next prompt, you will be asked to set a password for the MariaDB root user.
If you set up the validate password plugin, the script will show you the strength of your new password. Type
y to confirm the password.
Next, you’ll be asked to remove the anonymous user, restrict root user access to the local machine, remove the test database, and reload privilege tables. You should answer
y to all questions.
You can check the MariaDB version using the below command.
sudo mysqladmin version
Output mysqladmin Ver 9.1 Distrib 10.6.7-MariaDB, for debian-linux-gnu on x86_64 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Server version 10.6.7-MariaDB-2ubuntu1 Protocol version 10 Connection Localhost via UNIX socket UNIX socket /run/mysqld/mysqld.sock Uptime: 2 min 47 sec Threads: 1 Questions: 74 Slow queries: 0 Opens: 33 Open tables: 26 Queries per second avg: 0.443
Supercharge your Linux Administration Career with completed training course and get your dream job.
Now you have learned how to install MariaDB server on Ubuntu 22.04 and secure it.
Thanks for your time. If you face any problem or any feedback, please leave a comment below.