MariaDB is a community-developed fork of MySQL that provides a drop-in replacement with better performance, more storage engines, and active open source development. MariaDB 11.4 is the current recommended LTS release with support until 2029.
This guide covers installing MariaDB 11.4 LTS on Ubuntu 24.04 and 22.04 from the official MariaDB repository, securing the installation, and configuring it for production use. For the full release history, see the MariaDB Server releases page.
Prerequisites
- A server running Ubuntu 24.04 LTS or 22.04 LTS
- Root or sudo access
- Port 3306/tcp open if remote clients need access
Step 1: Add MariaDB Official Repository
Ubuntu’s default repos include MariaDB, but usually an older version. For the latest LTS, use the official MariaDB repository setup script.
sudo apt install -y curl
Download and run the repository setup script, specifying MariaDB 11.4 LTS.
curl -LsSO https://r.mariadb.com/downloads/mariadb_repo_setup
sudo bash mariadb_repo_setup --mariadb-server-version=11.4
The script auto-detects your Ubuntu version, adds the APT source, imports GPG keys, and runs apt update.
Step 2: Install MariaDB Server on Ubuntu
Install MariaDB server, client, and the backup tool.
sudo apt install -y mariadb-server mariadb-client mariadb-backup
Verify the installed version.
$ mariadb --version
mariadb Ver 15.1 Distrib 11.4.10-MariaDB, for debian-linux-gnu (x86_64) using readline 5.2
Step 3: Start and Enable MariaDB Service
The service usually starts automatically after installation. Verify and enable it for boot persistence.
sudo systemctl enable --now mariadb
Check the service status.
$ systemctl status mariadb
● mariadb.service - MariaDB 11.4.10 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: enabled)
Active: active (running)
Step 4: Secure MariaDB Installation
Run the security script to set the root password, remove test databases, and disable remote root login.
sudo mariadb-secure-installation
Answer the prompts:
- Enter current password for root – press Enter (no password set by default on Ubuntu)
- Switch to unix_socket authentication – No (keeps password auth available)
- Set root password – Yes, enter a strong password
- Remove anonymous users – Yes
- Disallow root login remotely – Yes
- Remove test database – Yes
- Reload privilege tables – Yes
Step 5: Test MariaDB Access
Connect to MariaDB using the root account.
$ sudo mariadb -u root -p
Enter password:
Welcome to the MariaDB monitor. Commands end with ; or \g.
Server version: 11.4.10-MariaDB-1:11.4.10+maria~ubu2404
MariaDB [(none)]> SELECT VERSION();
+------------------------------------------+
| VERSION() |
+------------------------------------------+
| 11.4.10-MariaDB-1:11.4.10+maria~ubu2404 |
+------------------------------------------+
1 row in set (0.000 sec)
Step 6: Create a Database and User
Create a database and a dedicated application user. Never use root for application connections.
MariaDB [(none)]> CREATE DATABASE appdb;
MariaDB [(none)]> CREATE USER 'appuser'@'%' IDENTIFIED BY 'StrongPass@2026';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON appdb.* TO 'appuser'@'%';
MariaDB [(none)]> FLUSH PRIVILEGES;
Replace '%' with a specific IP like '10.0.1.%' to restrict access to a subnet.
Step 7: Configure Firewall
If remote clients need to connect to MariaDB, allow port 3306 through UFW.
sudo ufw allow 3306/tcp
sudo ufw reload
Verify.
sudo ufw status | grep 3306
Step 8: Enable Remote Access (Optional)
MariaDB binds to 127.0.0.1 by default. To accept remote connections, edit the configuration.
sudo vi /etc/mysql/mariadb.conf.d/50-server.cnf
Find the bind-address line and change it:
[mysqld]
bind-address = 0.0.0.0
Restart MariaDB to apply.
sudo systemctl restart mariadb
Test from a remote machine.
mariadb -h 10.0.1.50 -u appuser -p appdb
Production Tuning Recommendations
For production deployments, add these settings to /etc/mysql/mariadb.conf.d/50-server.cnf under the [mysqld] section. Adjust values based on your server’s RAM.
[mysqld]
# InnoDB buffer pool - set to 70-80% of available RAM for dedicated DB servers
innodb_buffer_pool_size = 2G
# Log file size - larger values improve write performance
innodb_log_file_size = 512M
# Max connections - adjust based on your application needs
max_connections = 200
# Slow query log - helps identify performance issues
slow_query_log = 1
slow_query_log_file = /var/log/mysql/slow-query.log
long_query_time = 2
Restart MariaDB after making changes.
sudo systemctl restart mariadb
Conclusion
MariaDB 11.4 LTS is installed and secured on Ubuntu. For high availability setups, consider MariaDB Galera Cluster with HAProxy for multi-node replication. Monitor database performance with Prometheus and the MySQL exporter, and manage databases visually with phpMyAdmin.