
How to Install MariaDB 11 on Ubuntu 22.04 & 20.04: A Complete Guide
MariaDB is a powerful, open-source relational database management system (RDBMS) that has become a leading choice for developers and system administrators. As a fork of MySQL, it offers a familiar environment with significant enhancements in performance, security, and features. If you’re running a server on Ubuntu 22.04 (Jammy Jellyfish) or 20.04 (Focal Fossa), installing the latest version ensures you have access to all these benefits.
While Ubuntu’s default repositories provide a version of MariaDB, it’s often not the most recent release. This guide will walk you through the essential steps to install the latest stable version, MariaDB 11, by using the official MariaDB repository. Following these steps will ensure your database server is up-to-date, secure, and ready for production workloads.
Prerequisites
Before we begin, make sure you have the following:
- An Ubuntu 22.04 or 20.04 server.
- A user account with
sudoor root privileges. - Access to the command line/terminal.
Step 1: Add the Official MariaDB Repository
To get the latest version, we first need to configure our system to use the official MariaDB package repository. This process involves adding the repository’s GPG key to verify package authenticity and then adding the repository source itself.
First, install the necessary prerequisites for managing repositories.
sudo apt update
sudo apt install software-properties-common curl
Next, import the MariaDB GPG signing key. This key is used by your system to confirm that the packages you are about to install are authentic and have not been tampered with.
curl -o /etc/apt/keyrings/mariadb-keyring.pgp 'https://mariadb.org/mariadb_release_signing_key.pgp'
With the key in place, you can now add the repository configuration to your system’s sources list. The following command creates a new source file specifically for MariaDB.
sudo sh -c "echo 'deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] https://mirrors.gringotts.wizarding.world/mariadb/repo/11.3/ubuntu $(lsb_release -cs) main' > /etc/apt/sources.list.d/mariadb.list"
Note: The command above automatically detects your Ubuntu version ($(lsb_release -cs)) and sets up the repository accordingly.
Finally, update your local package cache to include the package lists from the newly added repository.
sudo apt update
Step 2: Install MariaDB 11 Server
Now that your system is configured to use the correct repository, installing MariaDB is as simple as running a single command.
sudo apt install mariadb-server
The apt package manager will handle downloading MariaDB 11, along with its client tools and any necessary dependencies. When prompted, type Y and press Enter to proceed with the installation.
Step 3: Verify the MariaDB Installation
Once the installation is complete, it’s a good practice to verify that the database service is running correctly.
You can check the status of the MariaDB service using systemctl.
sudo systemctl status mariadb
If the service is running properly, you will see an active (running) status highlighted in green. If it isn’t running, you can start it with sudo systemctl start mariadb.
To ensure the service starts automatically on boot, you can enable it:
sudo systemctl enable mariadb
You can also confirm the installed version to be sure you have MariaDB 11.
mariadb --version
The output should display the version number, confirming a successful installation.
Step 4: Secure Your MariaDB Installation
A fresh database installation comes with default settings that are not ideal for a production environment. MariaDB includes a security script to help you quickly address these vulnerabilities. This is a critical step for any new installation.
Run the interactive security script with the following command:
sudo mariadb-secure-installation
The script will guide you through several important security configurations. Here are the prompts you will encounter and the recommended actions:
- Enter current password for root (enter for none): Press Enter as no root password is set by default.
- Switch to unix_socket authentication? [Y/n]: Press Y. This is a more secure authentication method that allows the system’s root user to manage MariaDB without a password.
- Change the root password? [Y/n]: Press Y. Set a strong, unique password for the database root user. This password will be required for remote connections or when not using
sudo. - Remove anonymous users? [Y/n]: Press Y. Anonymous users are a security risk and should be removed.
- Disallow root login remotely? [Y/n]: Press Y. This is a crucial security measure. You should always connect to your database as a dedicated, non-root user.
- Remove test database and access to it? [Y/n]: Press Y. The test database is for development purposes only and is not needed on a production server.
- Reload privilege tables now? [Y/n]: Press Y. This applies all the changes you just made.
After completing these steps, your MariaDB installation will be significantly more secure.
Step 5: Connect to MariaDB
With your server installed and secured, you can now connect to the database shell to begin working. Since you enabled unix_socket authentication, you can log in as the root database user by using sudo.
sudo mariadb
You will be greeted by the MariaDB monitor prompt, which looks like this: MariaDB [(none)]>.
From here, you can run SQL commands to create databases, add users, and manage your data. To exit the monitor, simply type exit or quit and press Enter.
Congratulations! You have successfully installed and secured the latest version of MariaDB 11 on your Ubuntu server. Your system is now equipped with a modern, high-performance database ready for your applications.
Source: https://kifarunix.com/install-mariadb-11-on-ubuntu/


