UbuntuUbuntu Based

How To Install MariaDB on Ubuntu 24.04 LTS

Install MariaDB on Ubuntu 24.04

In this tutorial, we will show you how to install MariaDB on Ubuntu 24.04 LTS. MariaDB is a powerful, open-source relational database management system that serves as a robust alternative to MySQL. It offers enhanced performance, security, and features, making it an excellent choice for developers and system administrators alike.

This article assumes you have at least basic knowledge of Linux, know how to use the shell, and most importantly, you host your site on your own VPS. The installation is quite simple and assumes you are running in the root account, if not you may need to add ‘sudo‘ to the commands to get root privileges. I will show you the step-by-step installation of the MariaDB database on Ubuntu 24.04 (Noble Numbat). You can follow the same instructions for Ubuntu 22.04 and any other Debian-based distribution like Linux Mint, Elementary OS, Pop!_OS, and more as well.


  • A server running one of the following operating systems: Ubuntu and any other Debian-based distribution like Linux Mint.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • SSH access to the server (or just open Terminal if you’re on a desktop).
  • An active internet connection. You’ll need an internet connection to download the necessary packages and dependencies.
  • An Ubuntu 24.04 system with root access or a user with sudo privileges.

Install MariaDB on Ubuntu 24.04 LTS Noble Numbat

Step 1. Updating the Package Repository.

To begin, open your terminal and update the system packages to their latest versions. This step ensures that you have access to the most recent security patches and bug fixes. Run the following commands:

sudo apt update

This command will fetch the latest package information from the Ubuntu repositories, allowing you to install the most recent version of MariaDB and its dependencies. Updating the package repository is crucial to maintaining the security and stability of your system.

Step 2. Installing MariaDB on Ubuntu 24.04.

Ubuntu 22.04 includes MariaDB in its default repository, making the installation process straightforward. To install the latest version of MariaDB available in the repository, execute the following command:

sudo apt install mariadb-server

Step 3. Securing MariaDB Installation.

After the installation is complete, it’s crucial to secure your MariaDB server. MariaDB includes a handy script that guides you through the process of setting up basic security measures. Run the following command:

sudo mysql_secure_installation

The script will prompt you to set a root password, remove anonymous users, disable remote root login, and remove the test database. It is highly recommended to follow these security best practices to protect your MariaDB installation from unauthorized access.

Step 4. Configuring MariaDB.

With MariaDB installed and secured, you can now proceed to configure your databases and users. To access the MariaDB shell, use the following command:

sudo mysql

From within the MariaDB shell, you can create new databases, users, and grant appropriate permissions. For example, to create a new database named mydatabase and a user named myuser with full privileges on that database, execute the following commands:

CREATE USER 'myuser'@'localhost' IDENTIFIED BY 'mypassword';
GRANT ALL PRIVILEGES ON mydatabase.* TO 'myuser'@'localhost';

Remember to replace mydatabase, myuser, and mypassword with your desired values.

If you need to enable remote access to your MariaDB server, you can modify the bind-address setting in the MariaDB configuration file (/etc/mysql/mariadb.conf.d/50-server.cnf). Change the bind-address value from to to allow connections from any IP address. However, exercise caution when enabling remote access, as it exposes your database server to potential security risks.

Step 5. Managing MariaDB Services.

To manage the MariaDB server, you can use the systemctl command. Here are some essential commands to control the MariaDB service:

    • Start the MariaDB service:
sudo systemctl start mariadb
    • Stop the MariaDB service:
sudo systemctl stop mariadb
    • Restart the MariaDB service:
sudo systemctl restart mariadb
    • Check the status of the MariaDB service:
sudo systemctl status mariadb

To ensure that MariaDB starts automatically on system boot, run the following command:

sudo systemctl enable mariadb

Step 6. Troubleshooting Common Installation Issues.

If you encounter any issues during the MariaDB installation process, here are a few troubleshooting tips:

    1. If the MariaDB service fails to start, check the MariaDB error log (/var/log/mysql/error.log) for any specific error messages. Common issues include incorrect configuration settings or insufficient system resources.
    2. Ensure that the specified data directory (/var/lib/mysql) has the correct ownership and permissions. The directory should be owned by the mysql user and group, with appropriate read/write permissions.
    3. Verify that the MariaDB configuration file (/etc/mysql/mariadb.conf.d/50-server.cnf) contains valid settings and syntax. Incorrect configuration options can prevent the MariaDB service from starting.
    4. Check the system logs (/var/log/syslog) for any additional error messages or system-related issues that may impact the MariaDB installation.

If you continue to face difficulties, consult the official MariaDB documentation or seek assistance from the MariaDB community forums.

Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing the MariaDB powerful database on the Ubuntu 24.04 LTS system. For additional help or useful information, we recommend you check the MariaDB website.

VPS Manage Service Offer
If you don’t have time to do all of this stuff, or if this is not your area of expertise, we offer a service to do “VPS Manage Service Offer”, starting from $10 (Paypal payment). Please contact us to get the best deal!


r00t is a seasoned Linux system administrator with a wealth of experience in the field. Known for his contributions to idroot.us, r00t has authored numerous tutorials and guides, helping users navigate the complexities of Linux systems. His expertise spans across various Linux distributions, including Ubuntu, CentOS, and Debian. r00t's work is characterized by his ability to simplify complex concepts, making Linux more accessible to users of all skill levels. His dedication to the Linux community and his commitment to sharing knowledge makes him a respected figure in the field.
Back to top button