How to Install MariaDB Server on Ubuntu 24.04 LTS
This guide explains how to manually install and configure MariaDB Server on Ubuntu 24.04 LTS. These are the same steps that our Ansible playbook performs automatically.
Operating System: Ubuntu 24.04 LTS
Estimated Time: 10–15 minutes
Step 1 - Update the Package List
Update Ubuntu's package database to ensure the latest software versions are available.
sudo apt update
You should see Ubuntu downloading package information.
Step 2 - Install MariaDB Server
Install the MariaDB server, client tools, and the Python library used by Ansible.
sudo apt install mariadb-server mariadb-client python3-pymysql -y
The installation may take several minutes.
Step 3 - Verify MariaDB Installation
Check that MariaDB has been installed successfully.
mariadb --version
Example output:
mariadb Ver 15.1 Distrib 10.11.x-MariaDB
Step 4 - Enable MariaDB to Start Automatically
This ensures MariaDB starts automatically whenever the server boots.
sudo systemctl enable mariadb
Step 5 - Start MariaDB
Start the MariaDB database service.
sudo systemctl start mariadb
Step 6 - Check Service Status
Verify that the MariaDB service is running correctly.
sudo systemctl status mariadb
If everything is working correctly, you should see:
Active: active (running)
Press Q to exit the status screen.
Step 7 - Log Into MariaDB
Connect to the MariaDB server as the root user.
sudo mariadb
You should now see the MariaDB prompt:
MariaDB [(none)]>
Step 8 - Set the Root Password
Replace YourSecurePassword with your own strong password.
ALTER USER 'root'@'localhost'
IDENTIFIED BY 'YourSecurePassword';
Step 9 - Remove Anonymous Users
Delete anonymous accounts to improve security.
DELETE FROM mysql.user
WHERE User='';
Step 10 - Remove the Test Database
The test database is not needed on production servers.
DROP DATABASE IF EXISTS test;
Step 11 - Reload Privileges
Apply all security changes.
FLUSH PRIVILEGES;
Step 12 - Exit MariaDB
EXIT;
Step 13 - Log In Using Your New Password
Verify that the root password works.
sudo mariadb -u root -p
Enter the password you created in Step 8.
Step 14 - Verify the MariaDB Version
Once logged in, verify that the database is working correctly.
SELECT VERSION();
Example output:
+-----------------------------------+
| VERSION() |
+-----------------------------------+
| 10.11.14-MariaDB-0ubuntu0.24.04.1 |
+-----------------------------------+
Step 15 - Exit MariaDB
EXIT;
Verification Checklist
- ✔ MariaDB installed successfully
- ✔ MariaDB service is running
- ✔ Service starts automatically after reboot
- ✔ Root password configured
- ✔ Anonymous users removed
- ✔ Test database removed
- ✔ Successfully logged in using the root password
- ✔ Database version displayed successfully
You have successfully installed and secured MariaDB Server on Ubuntu 24.04 LTS. These are the same installation and configuration steps performed automatically by the accompanying Ansible playbook, allowing you to understand the manual process before automating it.

