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.