FedoraRHEL Based

How To Install MariaDB on Fedora 40

Install MariaDB on Fedora 40

In this tutorial, we will show you how to install MariaDB on Fedora 40. MariaDB is a popular open-source relational database management system that serves as a robust alternative to MySQL. As a fork of MySQL, MariaDB offers enhanced performance, security, and compatibility, making it an excellent choice for developers and system administrators. In Fedora 40, MariaDB has replaced MySQL as the default database system, providing users with a powerful and reliable solution for their database needs.

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 a Fedora 40.


Before we dive into the installation process, ensure that you have the following prerequisites in place:

  • A server running one of the following operating systems: Fedora 40.
  • It’s recommended that you use a fresh OS install to prevent any potential issues.
  • You will need access to the terminal to execute commands. Fedora provides the Terminal application for this purpose. It can be found in your Applications menu.
  • A stable internet connection to download the necessary packages.
  • A non-root sudo user or access to the root user. We recommend acting as a non-root sudo user, however, as you can harm your system if you’re not careful when acting as the root.

Install MariaDB on Fedora 40

Step 1. Update the System.

To ensure a smooth installation process, it is crucial to update your system packages to their latest versions. This step helps prevent potential conflicts and compatibility issues that may arise due to outdated packages. To update your Fedora 40 system, open a terminal and execute the following command:

sudo dnf clean all
sudo dnf update

This command will fetch the latest package information from the configured repositories and prompt you to confirm the installation of any available updates. Press “y” and hit Enter to proceed with the update process. Once the updates are installed, your system will be ready for the MariaDB installation.

Step 2. Installing MariaDB on Fedora 40.

To install the latest version of MariaDB on Fedora 40, you need to enable the MariaDB repository. This repository contains the most recent stable release of MariaDB, ensuring that you have access to the latest features, bug fixes, and security updates. Follow these steps to enable the MariaDB repository:

sudo dnf install dnf-utils

Enable the CodeReady Builder (CRB) repository using the following command:

sudo dnf config-manager --set-enabled crb

The CodeReady Builder repository includes MariaDB 10.6, which is the latest production-ready release of MariaDB at the time of writing. Enabling this repository ensures that you can install and use the most up-to-date version of MariaDB on your Fedora 40 system.

With the MariaDB repository enabled, you can now proceed to install the MariaDB server package. This package includes the core components required to set up and run a MariaDB database server on your Fedora 40 system. To install the MariaDB server, execute the following command in your terminal:

sudo dnf install mariadb-server

This command will fetch the MariaDB server package along with its dependencies, including the MariaDB client tools and backup utilities. During the installation process, you may be prompted to import the MariaDB GPG key. This key is used to verify the integrity and authenticity of the MariaDB packages. Confirm the import by pressing “y” and hitting Enter.

Once the installation is complete, you can verify the installed version of MariaDB by running:

mariadb --version

This command will display the version number of the installed MariaDB server.

To start the MariaDB service and enable it to automatically start at system boot, use the following commands:

sudo systemctl start mariadb
sudo systemctl enable mariadb

By default, MariaDB stores its data files in the /var/lib/mysql directory. It is important to note that SELinux, a security enhancement feature in Fedora, is enabled by default. SELinux enforces strict access controls, and it is preconfigured to allow MariaDB to access its data directory and other necessary resources.

Step 3. Secure MariaDB Installation.

After installing MariaDB, it is essential to secure your installation by running the mysql_secure_installation script. This script guides you through several security-related configurations to enhance the security of your MariaDB server. To run the script, execute the following command:

sudo mysql_secure_installation

The script will prompt you to set a root password for your MariaDB server. Choose a strong and secure password, following best practices such as using a combination of uppercase and lowercase letters, numbers, and special characters. Avoid using easily guessable or common passwords to protect your database from unauthorized access.

After completing the secure installation process, you can log in to your MariaDB server as the root user using the following command:

mysql -u root -p

Enter the root password you set during the secure installation process when prompted. This command will open the MariaDB prompt, where you can execute SQL commands and manage your databases.

Step 4. Create a Database.

If you want to create a new database for testing or development purposes, you can do so by executing SQL commands within the MariaDB prompt. To create a sample database and table, follow these steps:

Log in to the MariaDB server as the root user (if you haven’t already):

mysql -u root -p

At the MariaDB prompt, execute the following SQL commands to create a new database named testdb:

USE testdb;

Create a sample table named customers within the testdb database:

CREATE TABLE customers (

This command creates a table with three columns: id (an auto-incrementing integer primary key), name (a varchar column for storing customer names), and email (a varchar column for storing customer email addresses).

You can now insert sample data into the customers table using INSERT statements:

INSERT INTO customers (name, email) VALUES ('Meilana Doe', 'mei@example.com');
INSERT INTO customers (name, email) VALUES ('Maria Smith', 'lana@example.com');

These statements insert two sample records into the customers table.

Creating a sample database and table allows you to test your MariaDB installation and perform basic database operations. You can modify the table structure and insert additional data based on your specific requirements.

Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing the MariaDB database on your Fedora 40 system. For additional or useful information, we recommend you check the official 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