[フレーム]

How to Install and Secure MariaDB on Ubuntu 24.04

3 - 6 min read Sep 30, 2025

On Ubuntu 24.04, it doesn’t take much to get MariaDB running. Update the system first so the packages are current. Then install the server with apt install mariadb-server. Once it’s in place, check that the service came up cleanly. To lock it down, run mysql_secure_installation — that’s where you strip out the defaults attackers love to find.

This tutorial explains how to install MariaDB on Ubuntu and secure the configuration so it’s ready for real-world use. You’ll learn how to:

  • Update package indexes before installation
  • Install MariaDB with the apt install mariadb command
  • Check the service status and enable it at boot
  • Run mysql_secure_installation to handle the defaults that leave a fresh install exposed — the test database, anonymous accounts, and remote root logins. Once those are gone, the system is far less attractive to attackers.

Installing MariaDB on Ubuntu 24.04

On Ubuntu 24.04, the installation is straightforward. These steps show how to install MariaDB on Ubuntu systems cleanly and securely. Update the package lists, install the server package, and confirm the service is running. The last step is securing the defaults — removing test databases, anonymous accounts, and remote root access — so the system isn’t left exposed. Done in this order, MariaDB installs cleanly and is ready for real workloads.

Update Package Indexes

Before installing MariaDB, refresh the package indexes so Ubuntu pulls the latest information about software packages:

sudo apt update

This command only updates package lists; it doesn’t install or upgrade anything. Most administrators also follow with:

sudo apt upgrade -y

Running an upgrade at this stage keeps the system current and avoids dependency issues when you install MariaDB.

Install MariaDB

After updating the package indexes, bring in MariaDB with:

sudo apt install mariadb-server -y

This installs the server package and its dependencies in one step. During setup, you may be asked for confirmation; press "Y" to continue.

That single command installs the server and its dependencies. Many admins shorthand this as apt install mariadb when searching for the right syntax. If you’ve used MySQL before, note that mariadb install ubuntu works the same way — it’s designed as a drop-in replacement.

Ubuntu 24.04’s default repositories provide MariaDB 10.11 (the current long-term support release). If you need MariaDB 11.x features, add the official MariaDB APT repository — but confirm it supports Ubuntu 24.04 and is production-ready.

MariaDB was built as a fork of MySQL and remains fully compatible. In most cases, it can replace MySQL directly without breaking applications that rely on it.

Check MariaDB Status and Enable Auto-Start

After installing MariaDB, confirm that the service is running:

sudo systemctl status mariadb

If the output shows the service as active, enable it to start automatically on boot:

sudo systemctl enable mariadb

For another quick check, run mariadb --version to confirm the installed version, or connect directly with sudo mariadb. Both verify that the server is installed and working properly.

With the service confirmed, move on to securing the installation.

Secure the Installation

Run the secure installation script to close off the defaults that aren’t safe for production:

sudo mysql_secure_installation

The script covers the basics. It sets a root password, removes anonymous accounts, disables remote root login, drops the test database, and reloads the privilege tables. Each step reduces risk and tightens the configuration.

On Ubuntu, the root account usually uses Unix socket authentication, meaning sudo mariadb logs you in without a password. If you only manage MariaDB locally, socket authentication is safe and often easiest.

If you plan to connect remotely as root or through tools that require password-based login, switch to mysql_native_password and set a strong password:

ALTER USER 'root'@'localhost' IDENTIFIED VIA mysql_native_password USING 'your_strong_password';

Setting a root password is useful if you later change authentication methods or allow remote access.

Anonymous accounts should never remain in place. They let anyone connect without credentials. The same goes for the test database — it’s open to all users by default and should always be removed. Remote root logins are another weak point. Unless there’s a clear need for remote administration, keep them disabled.

When the script finishes, the privilege tables reload and the changes apply right away. The details may differ between environments, but the goal stays the same: reduce exposure and stop unwanted access.

Common Questions About MariaDB on Ubuntu

Even with the basics covered, a few questions often come up when installing and securing MariaDB.

Can MariaDB encrypt data?

Yes. MariaDB supports column-level encryption and tablespace/data-at-rest encryption (often called TDE). Availability depends on the build and version — in community editions, some features are limited. Many admins rely on full tablespace encryption when supported, while others use OS-level or disk encryption (e.g. LUKS) if TDE isn’t available.

How do I upgrade MariaDB?

On Ubuntu, keep MariaDB patched with:

sudo apt update && sudo apt upgrade -y

This brings in security and point releases. For major upgrades (e.g. 10.x → 11.x), you’ll need to add the MariaDB APT repository and follow the official upgrade steps — these are not always seamless and should be staged and tested first.

What’s the best way to back up a MariaDB database?

For small setups, mysqldump is quick and dependable. It dumps everything into a file you can restore anywhere. Larger environments run MariaDB’s native backup utilities instead, which handle incremental and full copies without dragging performance down. The tool doesn’t matter as much as the process. Test the backups. A file that’s never been restored isn’t a backup — it’s just a copy.

Where can I find more details on MariaDB?

The official MariaDB documentation has everything from basic configuration to performance tuning and advanced security. It’s the reference most admins keep open when they’re running MariaDB in production.

Final Thoughts: Install and Secure MariaDB on Ubuntu 24.04

MariaDB installs cleanly on Ubuntu 24.04 with apt install mariadb-server, but the real work is in what follows. Updating packages, checking the service, and running the secure installation script take away the weak defaults that make a fresh database easy to target.

Most admins will be fine with 10.11 from Ubuntu’s repositories if you need 11.x features, use the official MariaDB repo. Whatever the version, don’t skip the basics: patch the system, test your backups, and review configuration against your environment.

Set up this way, MariaDB isn’t just running — it’s hardened enough to handle production or development without leaving obvious gaps.

Get the Latest News & Insights

Sign up to get the latest security news affecting Linux and open source delivered straight to your inbox.

Please enable the javascript to submit this form " name="Submit" onclick="if (!window.__cfRLUnblockHandlers) return false; try{ return submitAcymForm('subscribe','formAcym87151', 'acymSubmitSubForm'); }catch(err){alert('The form could not be submitted '+err);return false;}" data-cf-modified-d5f579159008c6957ca22fa2-="" />
© 2024 Guardian Digital, Inc All Rights Reserved
You are now being logged in using your Facebook credentials

AltStyle によって変換されたページ (->オリジナル) /