Guides 11792 Published by

The guide shows how to install MariaDB 10.8 on Ubuntu 22.04 by first removing any pre‑existing MySQL or MariaDB packages, then adding the official repository and GPG key so that apt can fetch the newest build. It walks through updating apt, installing the specific 10.8 server and client packages, verifying that the service is active with systemctl, and starting it if necessary. After installation, the article recommends running mysql_secure_installation to set a root password and tighten defaults before connecting to confirm everything works. It also lists common pitfalls such as lost GPG keys or package conflicts and offers quick fixes like re‑adding the repo or using apt -f install, ensuring a smooth setup.



How to Install MariaDB 10.8 on Ubuntu 22.04 LTS

Installing MariaDB 10.8 is a breeze if you follow the right sequence. The guide walks through adding the official repository, installing the fresh package set, and getting the server up and running on Ubuntu 22.04 LTS.

Prerequisites and Cleanup

Before pulling in new packages, check whether an older MariaDB or MySQL instance already sits on the system. Running apt list --installed | grep -E 'mariadb|mysql' can reveal lingering versions that might conflict. If one is present, remove it with:

sudo apt purge mariadb-server mysql-server

This step clears out stale files and ensures a clean installation later.

Add the Official MariaDB Repository

Ubuntu’s default repositories ship MariaDB 10.6, which is fine for most use‑cases but falls short of the latest features in 10.8. The official repo is the safest way to get the newest build:

sudo apt install software-properties-common curl gnupg
curl -sS https://downloads.mariadb.org/mariadb_repo_setup | sudo bash

The script automatically detects Ubuntu 22.04 and writes /etc/apt/sources.list.d/mariadb.list with the correct entry. Adding the GPG key during this step also prevents “UNTRUSTED” warnings when updating.

Install MariaDB 10.8

With the repo in place, update the package list:

sudo apt update

Now install the full server stack:

sudo apt install mariadb-server=10.8.* mariadb-client-10.8

Specifying 10.8.* guarantees that apt pulls the desired major release instead of a newer or older one.

Verify That MariaDB Is Running

Check service status with systemd:

sudo systemctl status mariadb

You should see “active (running)”. If it’s dead, start it manually and enable autostart:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Connect to the server without a password to confirm access:

sudo mysql -u root -p

If you’re prompted for a password, the server is ready.

Secure the Installation

MariaDB ships with a helper script that removes insecure defaults. Run it as root and answer the prompts:

sudo mysql_secure_installation

Typical answers:

  • Set a strong root password.
  • Remove anonymous users (yes).
  • Disallow remote root login (yes for most local setups).
  • Drop test database (yes).

These steps close common attack vectors that can trip over when a server is exposed to the internet.

Common Pitfalls

Bad driver update and missing repo key: After a recent graphics driver upgrade on my coworker’s machine, MariaDB would not start because its GPG key was lost during the kernel change. Re‑adding the repository (step 2) solved it instantly.

Conflicting MySQL packages: If apt complains about package conflicts after step 3, run:

sudo apt -f install

This forces a fix of broken dependencies and usually clears up leftover MySQL components.

Version mismatch in scripts: Some legacy backup scripts reference mysql, not mariadb. Create an alias or update the shebang line to point at /usr/bin/mariadb to avoid errors during automated jobs.

That’s all there is to it. The official repository delivers MariaDB 10.8 right on Ubuntu 22.04 LTS, and a handful of commands get the server humming in no time.