MariaDB can be configured and operated reliably under Ubuntu 24.04 in just a few steps:
- Update Ubuntu
- Install MariaDB server via official package sources
- Secure the installation with the integrated security wizard
- Start the database service and verify that it is working correctly
- Create a user account and test access
Managed databases
Managed and secure databases
- Flexible solutions, tailored to your needs
- Professional-grade architecture, managed by experts
- Hosted in Europe, in accordance with the strictest data protection standards
Why install MariaDB on Ubuntu 24.04?
Ubuntu 24.04 “Noble Numbat” is a modern, stable and long-term supported Linux distribution. MariaDB offers, compared to MySQLadvanced features, better performance and is completely open source. The combination of the two is particularly suitable for web servers, development environments or as a database engine for applications like WordPress, Nextcloud or Home Assistant.
Prerequisites
Before you begin, make sure the following conditions are met:
- A system with Ubuntu 24.04 (server or desktop)
- Root access or a user with sudo rights
- Terminal access or SSH
Install MariaDB under Ubuntu 24.04: guide
Find out how to install MariaDB on Ubuntu 24.04 below. If you are using an earlier version of the latter, consult our dedicated articles: “Install MariaDB under Ubuntu 22.04” or “Install MariaDB under Ubuntu 20.04”.
Step 1: Update the system
First you need to update your Ubuntu system. This ensures that all packages are up to date and there are no conflicts during installation:
sudo apt update && sudo apt upgrade -y
bash
The packages are now up to date and the latest updates are installed.
Step 2: Install MariaDB
MariaDB is included in the official Ubuntu repository. You can install it directly via APT:
sudo apt install mariadb-server -y
bash
Step 3: Start and activate the MariaDB service
Start the MariaDB service with the following command:
sudo systemctl start mariadb
bash
To make MariaDB run automatically at system startup on Ubuntu, enable the service:
sudo systemctl enable mariadb
bash
Then check the status:
sudo systemctl status mariadb
bash
You should see output indicating that the service is active (running). If so, MariaDB is now successfully installed and started.
Step 4: Secure MariaDB
By default, MariaDB is configured relatively open after installation. You can change this with the security script integrated:
sudo mariadb_secure_installation
bash
Follow the instructions in the terminal. In particular, you can:
- Set a root password
- Delete anonymous user accounts
- Disable root access remotely
- Delete test database
- Reload authorization tables
Confirm with y. Now your MariaDB Ubuntu instance is significantly better protected against unauthorized access.
Advice
You can optionally unlock MariaDB port 3306 in the firewall only for trusted IP addresses. For example, if you want to allow an entire subnet (such as an internal corporate network), use the following command: sudo ufw allow from 192.168.0.0/24 to any port 3306. If only local use is intended, the corresponding command is sudo ufw deny 3306.
Step 5: Create a User and Database
Log in to the MariaDB console:
sudo mariadb -u root -p
bash
Enter the previously set password. You are now in the MariaDB shell and can run commands there.
Create a new database, for example for a web application or a CMS:
CREATE DATABASE db_example;
sql
Now add a user account, intended to access the database via an application:
CREATE USER 'webuser'@'localhost' IDENTIFIED BY 'safepassword';
sql
Make sure you use a secure password. Replace webuser and password by your own information.
The user account now needs the appropriate rights to the desired database:
GRANT ALL PRIVILEGES ON db_example.* TO 'webuser'@'localhost';
sql
This statement allows the user to perform all operations on the database db_example.
Enter the following command:
All rights are then immediately active. Finally, exit the database with:
Step 6: Test Access
You can now test if the new user can successfully access the database:
mariadb -u webuser -p db_example
bash
Insert the password you set previously. After successful login, you will see the MariaDB shell. There, you can check whether the database is accessible:
The database is empty unless you have previously created tables. However, this access test confirms that your configuration worked correctly.

