MariaDB can be set up and run reliably on Ubuntu 24.04 in just a few steps:

  1. Update Ubuntu

  2. Install MariaDB server via the official package sources

  3. Secure the in­stal­la­tion with the in­te­grat­ed security assistant

  4. Start the database service and check for correct func­tion­al­i­ty

  5. Create a user account and test access

Managed Databases
Time-saving database services
  • En­ter­prise-grade ar­chi­tec­ture managed by experts
  • Flexible solutions tailored to your re­quire­ments
  • Leading security in ISO-certified data centers

Why install MariaDB on Ubuntu 24.04?

Ubuntu 24.04 “Noble Numbat” is a modern, stable and long-term supported Linux dis­tri­b­u­tion. MariaDB offers advanced features, better per­for­mance compared to MySQL and is fully open source. The com­bi­na­tion is es­pe­cial­ly suitable for web servers, de­vel­op­ment en­vi­ron­ments or as a database backend for ap­pli­ca­tions like WordPress, Nextcloud or Home Assistant.

What are the re­quire­ments?

Before you start, make sure the following pre­req­ui­sites are met:

  • A system with Ubuntu 24.04 (Server or Desktop)
  • Root access or a user with sudo priv­i­leges
  • Terminal or SSH access

How to install Ubuntu 24.04 on MariaDB

In this tutorial, we explain how to install MariaDB on Ubuntu 24.04. If you are using an older version, we recommend checking out our other guides.

Step 1: Update the system

Start by updating your Ubuntu system. This ensures that all packages are up to date and helps avoid conflicts during in­stal­la­tion:

sudo apt update && sudo apt upgrade -y
bash

This command refreshes the package lists and installs all available updates.

Step 2: Install MariaDB on Ubuntu

MariaDB is included in the official Ubuntu repos­i­to­ry. You can install it directly using APT:

sudo apt install mariadb-server -y
bash
Compute Engine
The ideal IaaS for your workload
  • Cost-effective vCPUs and powerful dedicated cores
  • Flex­i­bil­i­ty with no minimum contract
  • 24/7 expert support included

Step 3: Start and enable the MariaDB service

Start the MariaDB service using the following command:

sudo systemctl start mariadb
bash

Enable the service so MariaDB au­to­mat­i­cal­ly runs at system startup:

sudo systemctl enable mariadb
bash

Check its status:

sudo systemctl status mariadb
bash

You should see output showing that the service is active (running). If so, MariaDB has been suc­cess­ful­ly installed and started.

Step 4: Secure MariaDB

By default, MariaDB is rel­a­tive­ly open after in­stal­la­tion. To make it more secure, run the built-in security script:

sudo mariadb_secure_installation
bash

Follow the on-screen in­struc­tions. You can, among other things:

  • Set a root password
  • Remove anonymous user accounts
  • Disable remote root access
  • Remove the test database
  • Reload the privilege tables

Type y to confirm each change. This makes your MariaDB Ubuntu in­stal­la­tion sig­nif­i­cant­ly more secure against unau­tho­rized access.

Tip

You can also restrict access to MariaDB port 3306 by allowing only trusted IP addresses. For example, to allow an internal company subnet use: sudo ufw allow from 192.168.0.0/24 to any port 3306. If only local use is planned, run: sudo ufw deny 3306.

Step 5: Create a user and a database

Log in to the MariaDB console:

sudo mariadb -u root -p
bash

Enter the root password you set earlier. You are now in the MariaDB shell and can execute commands.

Create a new database, for example for a web ap­pli­ca­tion or a CMS:

CREATE DATABASE db_example;
sql

Now create a user account that can access this database:

CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'safepassword';
sql

Replace webuser and safepassword with your own details. Make sure to use a secure password.

Grant per­mis­sions to the user on the new database:

GRANT ALL PRIVILEGES ON db_example.* TO 'webuser'@'localhost';
sql

This gives the user full access to the db_example database.

Finally, activate the priv­i­leges im­me­di­ate­ly with:

FLUSH PRIVILEGES;
sql

Exit the shell with:

EXIT;
sql

Step 6: Test access

Now test if the new user can connect to the database:

mariadb -u webuser -p db_example
bash

Enter the password you set earlier. If suc­cess­ful, you’ll be logged into the MariaDB shell. Inside the shell, run a simple command to confirm access:

SHOW TABLES;
sql

Since no tables exist yet, the database will be empty. This test confirms that the setup and per­mis­sions are working correctly.

Go to Main Menu