In this tutorial, we are going to explain how to install the MariaDB database service on Ubuntu 24.04 OS. MariaDB is an open-source relational database management system, a replacement for MySQL with many improvements, such as performance, flexibility, and reliability. MariaDB includes advanced features like Galera Clustering and various data type support. MariaDB was created by the original MySQL developers due to concerns over its acquisition by Oracle. In the next paragraphs, we will explain the steps for installing, securing, and using the MariaDB database service.
The installation of MariaDB is a straighforward process and may take up to 10 minutes. Let’s get started!
Prerequisites
- A server running Ubuntu 24.04 OS
- User privileges: root or non-root user with sudo privileges
Step 1. Update the System
We assume that you have a fresh Ubuntu 24.04 OS. Before we start with the installation of the MariaDB we need to update the system packages. To do that execute the following command:
sudo apt update -y && sudo apt upgrade -y
Step 2. Install MariaDB database
MariaDB is already included in the repository of Ubuntu 24.04, and to install the MariaDB database management system, execute the following command:
sudo apt install mariadb-server -y
To start and enable the MariaDB database service, you can use the following commands:
sudo systemctl start mariadb && sudo systemctl enable mariadb
To check the status of the MariaDB service, you can use the command below:
sudo systemctl status mariadb
You should get the following outptut:
root@host:~# sudo systemctl status mariadb
● mariadb.service - MariaDB 10.11.13 database server
Loaded: loaded (/usr/lib/systemd/system/mariadb.service; enabled; preset: enabled)
Active: active (running) since Sat 2025-10-25 17:17:23 CDT; 37s ago
Docs: man:mariadbd(8)
https://mariadb.com/kb/en/library/systemd/
Main PID: 3556 (mariadbd)
Status: "Taking your SQL requests now..."
Tasks: 13 (limit: 30378)
Memory: 78.7M (peak: 81.6M)
CPU: 1.045s
CGroup: /system.slice/mariadb.service
└─3556 /usr/sbin/mariadbd
Step 3. Securing the MariaDB Installation
The most important step after the installation is securing the MariaDB installation. This is important to prevent unauthorized access and corruption. To ensure the MariaDB installation, execute the command below:
sudo mariadb-secure-installation
After executing the command, you should follow the next steps in order to secure the MariaDB installation:
Enter current password for root (enter for none): Switch to unix_socket authentication [Y/n] Y Change the root password? [Y/n] Y New password: StrongROOTPasswordHere Re-enter new password: StrongROOTPasswordHere Remove anonymous users? [Y/n] Y Disallow root login remotely? [Y/n] Y Remove test database and access to it? [Y/n] Y Reload privilege tables now? [Y/n] Y ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Most Useful MariaDB commands
Here’s a useful list of the most important and commonly-used commands/SQL statements for MariaDB:
CREATE DATABASE db_name; Create a new database. DROP DATABASE db_name; Delete an existing database. USE db_name; Select a database to work with. CREATE TABLE table_name ( … ); Create a new table structure. ALTER TABLE table_name …; Modify the structure of an existing table. DROP TABLE table_name; Remove a table and its data. DESCRIBE table_name; or SHOW COLUMNS FROM table_name; Show table structure. SELECT … FROM …; Read data from tables. INSERT INTO table_name (…) VALUES (…); Insert new rows of data. UPDATE table_name SET … WHERE …; Modify existing data. DELETE FROM table_name WHERE …; Delete data from a table. SHOW DATABASES; List all databases on the server. SHOW TABLES; List all tables in the current database. SHOW COLUMNS FROM table_name; Show columns (fields) in a table. SHOW INDEX FROM table_name; Show index information for a table. SHOW TABLE STATUS LIKE 'table_name'; Show detailed table status (engine, size, etc). DESCRIBE table_name; Alias for showing structure of a table. CREATE USER 'user'@'host' IDENTIFIED BY 'password'; Create a new user GRANT privileges ON db.table TO 'user'@'host'; Give permissions to a user. REVOKE privileges ON db.table FROM 'user'@'host'; Remove permissions. FLUSH PRIVILEGES; Reload the privileges tables so changes take effect.
Those are the most used and most important MariaDB commands, but the most important one is the logging to the MariaDB console. Without logging to the console, you are not able to execute any of the provided commands above. The command for login is:
mariadb -u user_name -p
Here is a brief explanations of the login command:
mariadb = client command. -u user_name = specify which database user you want to use. -p = prompt for a password (safer than putting it directly on command line).
If you want to connect to a specific database at login:
mariadb -u user_name -p database_name
To connect to a remote host, include -h host_name_or_ip and optionally -P port:
mariadb -u user_name -p -h 192.168.1.100 -P 3306 database_name
A common secure login command:
mariadb -u root -p
Then you’ll be prompted:
root@host:~# mariadb -u root -p Enter password:
After successful login, you will get the following output:
root@host:~# mariadb -u root -p Enter password: Welcome to the MariaDB monitor. Commands end with ; or \g. Your MariaDB connection id is 41 Server version: 10.11.13-MariaDB-0ubuntu0.24.04.1 Ubuntu 24.04 Copyright (c) 2000, 2018, Oracle, MariaDB Corporation Ab and others. Type 'help;' or '\h' for help. Type '\c' to clear the current input statement. MariaDB [(none)]>
That’s it. You successfully installed MariaDB database service on Ubuntu 24.04 OS.
If you liked this post about installing MariaDB on Ubuntu 24.04, please share it with your friends or leave a comment down below.