Databases

Install MariaDB 11.8 on Ubuntu 24.04|22.04

MariaDB is an open-source relational database management system that serves as a drop-in replacement for MySQL. It is the default database in most Linux distributions and powers applications ranging from small projects to enterprise workloads.

Original content from computingforgeeks.com - post 114

This guide covers installing MariaDB 11.8 LTS on Ubuntu 24.04 or 22.04 from the official MariaDB APT repository. Ubuntu’s default repositories ship older MariaDB versions (10.11 on 24.04, 10.6 on 22.04), but 11.8 is the latest Long Term Support release with community support until June 2028. The official MariaDB repo provides the same 11.8 packages for both Ubuntu versions.

Prerequisites

  • A server running Ubuntu 24.04 or 22.04 LTS
  • Root or sudo access
  • Port 3306/TCP if you need remote database connections

Step 1: Update System Packages

Start by updating all system packages:

sudo apt update && sudo apt -y upgrade

Reboot if a kernel update was applied:

[ -f /var/run/reboot-required ] && sudo reboot -f

Step 2: Add MariaDB 11.8 APT Repository

Ubuntu default repositories include older MariaDB versions. To install the latest LTS (11.8), add the official MariaDB repository.

Download the MariaDB signing key:

sudo mkdir -p /etc/apt/keyrings
sudo curl -fsSL -o /etc/apt/keyrings/mariadb-keyring.pgp https://mariadb.org/mariadb_release_signing_key.pgp

Add the MariaDB 11.8 repository. Use noble for Ubuntu 24.04 or jammy for Ubuntu 22.04:

For Ubuntu 24.04:

echo "deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] https://dlm.mariadb.com/repo/mariadb-server/11.8/repo/ubuntu noble main" | sudo tee /etc/apt/sources.list.d/mariadb.list

For Ubuntu 22.04:

echo "deb [signed-by=/etc/apt/keyrings/mariadb-keyring.pgp] https://dlm.mariadb.com/repo/mariadb-server/11.8/repo/ubuntu jammy main" | sudo tee /etc/apt/sources.list.d/mariadb.list

Update the package index to pull in packages from the new repository:

sudo apt update

Confirm that MariaDB 11.8 is now the candidate version:

apt policy mariadb-server

The output should show MariaDB 11.8 from the official repo as the candidate. On Ubuntu 24.04 it looks like this (22.04 shows ubu2204 and jammy instead):

mariadb-server:
  Installed: (none)
  Candidate: 1:11.8.6+maria~ubu2404
  Version table:
     1:11.8.6+maria~ubu2404 500
        500 https://dlm.mariadb.com/repo/mariadb-server/11.8/repo/ubuntu noble/main amd64 Packages
     1:10.11.14-0ubuntu0.24.04.1 500
        500 http://archive.ubuntu.com/ubuntu noble-updates/universe amd64 Packages

Step 3: Install MariaDB Server

Install both the server and client packages:

sudo apt install -y mariadb-server mariadb-client

MariaDB starts automatically after installation. Verify the service is running:

systemctl status mariadb

The output should show active (running) with the version confirmed in the status line:

● mariadb.service - MariaDB 11.8.6 database server
     Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: enabled)
     Active: active (running) since Sat 2026-03-21 21:09:11 UTC; 17s ago
       Docs: man:mariadbd(8)
             https://mariadb.com/kb/en/library/systemd/
   Main PID: 27168 (mariadbd)
     Status: "Taking your SQL requests now..."
      Tasks: 13 (limit: 15318)
     Memory: 92.8M
        CPU: 4.078s
     CGroup: /system.slice/mariadb.service
             └─27168 /usr/sbin/mariadbd

Confirm the installed version from the command line:

mariadb --version

The version string confirms MariaDB 11.8 is installed:

mariadb from 11.8.6-MariaDB, client 15.2 for debian-linux-gnu (x86_64) using  EditLine wrapper

Step 4: Secure MariaDB Installation

Run the security script to set a root password, remove anonymous users, disable remote root login, and drop the test database:

sudo mariadb-secure-installation

Answer the prompts as follows for a production setup:

Enter current password for root (enter for none): Press Enter
Switch to unix_socket authentication [Y/n] Y
Change the root password? [Y/n] Y
New password: Enter a strong password
Re-enter new password: Confirm password
Remove anonymous users? [Y/n] Y
Disallow root login remotely? [Y/n] Y
Remove test database and access to it? [Y/n] Y
Reload privilege tables now? [Y/n] Y

Step 5: Connect to MariaDB and Verify

Connect to the MariaDB shell. With unix_socket authentication enabled, the root system user can connect directly with sudo:

sudo mariadb

Check the server version from the SQL prompt:

MariaDB [(none)]> SELECT VERSION();
+-------------------------+
| VERSION()               |
+-------------------------+
| 11.8.6-MariaDB-ubu2404  |
+-------------------------+
1 row in set (0.000 sec)

On Ubuntu 22.04, the version string ends with ubu2204 instead. The MariaDB version (11.8.6) is the same on both.

Step 6: Basic MariaDB Usage

Here are the most common database operations you will need after installation.

Create a Database and User

sudo mariadb

Create a new database, a dedicated user with a password, and grant full privileges on that database:

MariaDB [(none)]> CREATE DATABASE appdb;
MariaDB [(none)]> CREATE USER 'appuser'@'localhost' IDENTIFIED BY 'Str0ngP@ss!';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;

Create a Table and Insert Data

Switch to the new database, create a table, and insert a row:

MariaDB [(none)]> USE appdb;
MariaDB [appdb]> CREATE TABLE users (id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(50), email VARCHAR(100));
MariaDB [appdb]> INSERT INTO users (name, email) VALUES ('John Doe', '[email protected]');
MariaDB [appdb]> SELECT * FROM users;

The query returns the inserted row:

+----+----------+------------------+
| id | name     | email            |
+----+----------+------------------+
|  1 | John Doe | [email protected] |
+----+----------+------------------+
1 row in set (0.000 sec)

Type QUIT to exit the MariaDB prompt.

Step 7: Configure Remote Access (Optional)

By default, MariaDB listens only on 127.0.0.1. To allow connections from other servers, edit the server configuration file:

sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf

Find the bind-address directive and change it to 0.0.0.0 to listen on all interfaces, or set it to a specific IP:

[mysqld]
bind-address = 0.0.0.0

Restart MariaDB to apply the change:

sudo systemctl restart mariadb

Verify MariaDB is listening on all interfaces:

ss -tlnp | grep 3306

The output should show 0.0.0.0:3306 instead of 127.0.0.1:3306:

LISTEN 0      80           0.0.0.0:3306      0.0.0.0:*

Open the firewall port for remote connections:

sudo ufw allow 3306/tcp
sudo ufw reload

Grant access to the remote user. Replace 10.0.1.5 with the IP of the connecting server:

sudo mariadb -e "GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'10.0.1.5' IDENTIFIED BY 'Str0ngP@ss!'; FLUSH PRIVILEGES;"

Conclusion

MariaDB 11.8 LTS is now running on your Ubuntu server from the official MariaDB repository. The server listens on port 3306 and is secured with mariadb-secure-installation.

For production use, set up MariaDB replication for high availability, configure automated backups with mariadb-dump or mariabackup, and consider enabling Prometheus monitoring for MariaDB to track query performance and resource usage.

Related Articles

AlmaLinux Install Apache Cassandra on Rocky Linux 10 / AlmaLinux 10 Git Install Sourcegraph code search engine on Ubuntu 24.04|22.04|20.04| Fedora Ubuntu 22.04 vs Fedora 36 – Comparison Table Featured Using Emacs on Linux and macOS – emac Commands examples

Leave a Comment

Press ESC to close