Guides 11792 Published by

This guide walks you through installing MariaDB 10.9 on Ubuntu 22.04 LTS, explaining why the newer version offers thread‑pooling and improved JSON handling over the default 10.3 that ships in the official repositories. It begins by purging any lingering MySQL or MariaDB packages so a clean install can proceed without conflicting libraries, then adds MariaDB’s own repository using a script that also imports the proper GPG key. After updating the package cache you install the server, run `mysql_secure_installation` to lock it down, and optionally enable thread pooling by editing `/etc/mysql/mariadb.conf.d/99-threadpool.cnf` before restarting the service. Finally, the article shows how to verify the installation with a quick query, lists common pitfalls such as missing updates or stray binaries, and reminds you to adjust bind‑address settings if remote access is needed.



Install MariaDB 10.9 on Ubuntu 22.04 LTS – Step‑by‑Step Guide

When you’ve got a fresh Ubuntu 22.04 LTS install or a server that needs the latest MySQL drop‑in, MariaDB 10.9 is the sweet spot. It ships with thread‑pooling tweaks and better JSON support that keep your apps snappy. Below is a no‑frills walkthrough of how to get it up and running, plus a few tips I’ve learned after wiping out a corrupted DB on a test box.

1. Prerequisites – Clean Slate

Before you even touch `apt`, make sure there are no old MariaDB or MySQL packages hanging around. A half‑installed server can cause version clashes that look like magic and then break your application.

sudo apt purge mariadb- mysql-
sudo apt autoremove

Why this matters: removing leftovers guarantees the new repository will drop a clean 10.9 package stack instead of mixing 10.3 with 10.9, which leads to duplicate libraries and erratic behavior.

2. Adding the Official MariaDB Repository

Ubuntu’s default repos ship MariaDB 10.3. To get 10.9 you must point `apt` at MariaDB’s own repo.

# Install required tools if missing
sudo apt install -y wget gnupg ca-certificates lsb-release

# Grab the MariaDB GPG key (verify the fingerprint in your browser!)
wget -O- https://downloads.mariadb.org/mariadb_repo_setup | sudo bash -s -- --mariadb-server-version=10.9

The `mariadb_repo_setup` script automatically detects your Ubuntu version and writes a proper `/etc/apt/sources.list.d/mariadb.list`. It also adds the GPG key so Debian’s package manager can verify integrity.

3. Updating the Package Cache
sudo apt update

Why? `apt` needs to know about the new repo before you ask it for MariaDB 10.9; otherwise it will still look in Ubuntu’s older archive and give you a 10.3 install.

4. Installing MariaDB 10.9
sudo apt install -y mariadb-server

A quick sanity check right after the install:

mariadb --version
# => MariaDB [(none)] version 10.9.x

If you see a different number, something went wrong—check the output of `apt policy mariadb-server` to confirm it’s pulling from `/etc/apt/sources.list.d/mariadb.list`.

5. Securing Your New Installation

Like every database server on the internet, MariaDB should be locked down.

sudo mysql_secure_installation

During this interactive script you’ll set a root password, remove anonymous accounts, disallow remote root login, and delete the test database. I’ve found that forgetting to run `mysql_secure_installation` often leads to people accidentally connecting from a public IP—an embarrassing security hole.

6. Optional: Enabling Thread Pooling

MariaDB 10.9 comes with thread pooling built‑in, but you need to enable it manually if your workload is highly concurrent.

Create or edit `/etc/mysql/mariadb.conf.d/99-threadpool.cnf`:

[thread_pool]
enabled=1
min_spare_threads=5
max_spare_threads=10

Then reload the service:

sudo systemctl restart mariadb

Why bother? On a server with dozens of simultaneous connections, thread pooling can reduce context‑switch overhead and keep latency low.

7. Verifying Everything Works

Open the MariaDB shell and run a quick query:

sudo mysql -uroot -p
MariaDB> SHOW VARIABLES LIKE 'version%';

You should see `10.9.x`. Try creating a test database to confirm write operations succeed:

CREATE DATABASE testdb;
USE testdb;
CREATE TABLE foo (id INT PRIMARY KEY AUTO_INCREMENT, bar VARCHAR(50));
INSERT INTO foo (bar) VALUES ('hello');
SELECT * FROM foo;

If the row appears, congratulations—your MariaDB 10.9 installation is functional.

8. Common Pitfalls & Quick Fixes
  • “Package ‘mariadb-server’ not found” – Double‑check you ran `sudo apt update` after adding the repo.
  • Old binaries still present – Run `dpkg -l | grep mariadb` to see if any old versions linger; purge them again.
  • Connection refused on remote host – Make sure `/etc/mysql/mariadb.conf.d/50-server.cnf` has `bind-address = 0.0.0.0` or your server’s IP, and that the firewall allows port 3306.

That’s it. MariaDB 10.9 is now humming on Ubuntu 22.04 LTS, ready for production workloads or tinkering in a dev environment. Give it a spin, tweak `thread_pool`, and watch those queries get faster without all the bloat of an older build.