April 16, 2025
Tutorials

How to Install MariaDB on Ubuntu 24.04

Install MariaDB on Ubuntu 24.04

MariaDB is an open-source software that is widely known as an alternative to MySQL. It has many features, including ACID compliance, high performance, and scalability. Users can create and manage databases, along with running SQL queries with ease after installing MariaDB. The goal of installing MariaDB on Ubuntu 24.04 is to provide the system with a powerful and trustworthy relational database management system (RDBMS) for the storage, retrieval, and management of data for several applications.

This article will guide you through the steps of installing or uninstalling MariaDB.

How to Install MariaDB on Ubuntu 24.04?

How to Uninstall MariaDB on Ubuntu 24.04?

How to Install MariaDB on Ubuntu 24.04?

No matter what web applications you’re building, whether you require a content management system or any other software that supports a database, MariaDB can support all of your needs.

Method 1: Using the Ubuntu Default Repository

Method 2: Using the MariaDB Repository

Let’s start with the simpler method first.

Method 1: Using the Ubuntu Default Repository

Here are the steps to install MariaDB on Ubuntu 24.04 by utilizing the Ubuntu repository:

Step 1: Updating the Package Index

To use the Ubuntu default repository, users first need to update the system repository to update the package index by utilizing the apt command.

sudo apt update
sudo apt update

Step 2: Install the mariadb-server Package

Now, use the apt command to install the mariadb-server package as a sudo user.

sudo apt install mariadb-server
sudo apt install mariadb-server

Step 3: Securing MariaDB Installation

Execute the mysql_secure_installation script to limit access permissions to the server, and improve security after installation. This script walks users through a few prompts that help dictate how secure the MariaDB Installation would be:

sudo mysql_secure_installation
sudo mysql_secure_installation

While executing the script, a prompt will come up that will require you to set a current database password that needs to be assigned to the root user. If users haven’t set one yet, users can just hit ENTER to mean none. Other security options will also be made available for you as the script guides you.

sudo mysql_secure_installation

Step 4: Verification of the MariaDB Installation

To confirm, log in to the MariaDB shell under the root user and provide the password.

sudo mysql -u root -p
sudo mysql -u root -p

Optional: Updating MariaDB on Ubuntu 24.04

In order to install or upgrade to the latest version of MariaDB on Ubuntu, the system packages should be updated, the MariaDB APT repository should be added, followed by installing the MariaDB11.0 server/ client. After that, a secure installation of the MariaDB, followed by a test for the installation.

sudo mariadb-upgrade
sudo mariadb-upgrade

Users can also upgrade by employing the “mariadb-upgrade” command. This is taken from method 1.

Method 2: Using the MariaDB Repository

In order to upgrade to the newest MariaDB version for Ubuntu 24.04, the official fare is recommended. This is how you install MariaDB on Ubuntu 24.04 using the MariaDB repository:

Step 1: Update Package list

In this case, make sure your system packages list is up-to-date so you are using the most recent version.

sudo apt update
sudo apt update

Step 2: Install Software Properties

Users are now prompted to install the sister package which is crucial for adding the new repositories.

sudo apt install software-properties-common
sudo apt install software-properties-common

Step 3: Import the MariaDB GPG Key

Use the “apt-key” command to import the MariaDB GPG Key to check the repository’s authenticity.

sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'
sudo apt-key adv --fetch-keys 'https://mariadb.org/mariadb_release_signing_key.asc'

Step 4: Add the MariaDB Repository

Now, append the MariaDB repository to the system. For this purpose, you must substitute “11.2.3” with the version you like to install:

sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/11.2.3/ubuntu jammy main'
sudo add-apt-repository 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/11.2.3/ubuntu jammy main'

Note: Should the Ubuntu version have a different codename, the “jammy” could be substituted in the repository line. If the codename is not recognized automatically, substitute $(lsb_release -cs) with the codename of the Ubuntu version.

Step 5: Update Packages List

To enable installation of the MariaDB from the included repository, update the package’s indexing:

sudo apt update
sudo apt update

Step 6: Install MariaDB Server

Now, users can download the MariaDB server and client packages from the official repository for MariaDB:

sudo apt install mariadb-server mariadb-client
sudo apt install mariadb-server mariadb-client

Step 7: Secure MariaDB Installation (optional but recommended)

In this step, run the script to assign a root password. The following script will prompt users for additional security measures that may be taken as well:

sudo mysql_secure_installation
sudo mysql_secure_installation

Step 8: Verify Installation

Now, confirm that the installed MariaDB is operational. To do so, review the status of the MariaDB service:

sudo systemctl status mariadb
sudo systemctl status mariadb

Alternatively, the users may use the mysql command to connect to the MariaDB as follows:

sudo mysql -u root -p
sudo mysql -u root -p

That would be all for this procedure for the most recent version of MariaDB.

How to Uninstall MariaDB on Ubuntu 24.04?

In order to delete MariaDB from Ubuntu 24.04, users may run the command ‘auto-remove’ like so:

sudo apt autoremove mariadb-server mariadb-client --purge -y # For Removing Packages 
sudo add-apt-repository --r 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/11.2.3/ubuntu jammy main' # For Removing Repository
sudo add-apt-repository --r 'deb [arch=amd64] http://mariadb.mirror.globo.tech/repo/11.2.3/ubuntu jammy main'

This will delete the server components alongside the client components for MariaDB.

Conclusion

To download and set up MariaDB on Ubuntu 24.04, one needs to first update the package index and then install the MariaDB server package by executing “sudo apt install mariadb-server”. To make the system secure then one must run the “mysql_secure_installation” script after the installation is done alongside configuring MariaDB.

In order to get the latest version of MariaDB on Ubuntu 24.04, the MariaDB repository needs to be added then the mariadb-server and mariadb-client packages need to be installed for them to be used. To access/start MariaDB as a newly added user, run the command “mysql -u myuser -p”. Thereafter, enter the password of the user. This is how users are able to create tables, add some data, and execute SQL statements in the database.

Frequently Asked Questions

MariaDB is an open-source relational database management system (RDBMS) and a popular drop-in replacement for MySQL. It's known for its high performance, stability, and security.
You can install MariaDB on Ubuntu 24.04 by running the command: sudo apt update && sudo apt install mariadb-server
Yes, you should secure the installation using: sudo mysql_secure_installation
To check if MariaDB is running, use the following command:sudo systemctl status mariadb
To enable MariaDB to start automatically at boot, use this command:sudo systemctl enable mariadb

Leave feedback about this

  • Quality
  • Price
  • Service

PROS

+
Add Field

CONS

+
Add Field
Choose Image
Choose Video