FedoraRHEL Based

How To Install MariaDB on Fedora 38

Install MariaDB on Fedora 38

In this tutorial, we will show you how to install MariaDB on Fedora 38. If you’re looking to install MariaDB on your Fedora 38 system, you’re in the right place. MariaDB is a popular fork of MySQL that offers additional features and enhancements, and the installation process is straightforward. However, if you’re new to Fedora 38, you might need a bit of guidance. Whether you’re a seasoned developer or just getting started with MariaDB, this guide will help you get up and running quickly and easily. So, let’s dive in and get your MariaDB installation set up on Fedora 38!

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 38.

Prerequisites

  • A server running one of the following operating systems: Fedora 38.
  • 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 for MariaDB.
  • 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 38

Step 1. Before we can install MariaDB on Fedora 38, it’s important to ensure that our system is up-to-date with the latest packages. This will ensure that we have access to the latest features and bug fixes and that we can install MariaDB without any issues:

sudo dnf upgrade --refresh

Step 2. Installing MariaDB on Fedora 38.

To install MariaDB on Fedora 38, you need to add the MariaDB Repository first. Now copy and paste it into a file under /etc/yum.repos.d (we suggest naming the file MariaDB.repo or something similar).

# MariaDB 10.11 Fedora repository list - created 2023-04-28 17:09 UTC
# https://mariadb.org/download/
[mariadb]
name = MariaDB
# baseurl = https://rpm.mariadb.org/10.11/fedora/$releasever/$basearch
baseurl = https://mirror.rackspace.com/mariadb/yum/10.11/fedora/$releasever/$basearch
# gpgkey= https://rpm.mariadb.org/RPM-GPG-KEY-MariaDB
gpgkey=https://mirror.rackspace.com/mariadb/yum/RPM-GPG-KEY-MariaDB
gpgcheck=1

Now that you have added the MariaDB Yum Repository, you can proceed and install MariaDB on your Fedora 38 system using the following command:

sudo dnf install MariaDB-server MariaDB-client

Once MySQL has been installed on your system, start the MySQL service by running the following command in the terminal:

sudo systemctl start mariadb
sudo systemctl enable mariadb

Step 3. Securing MariaDB on Fedora 38

Once you have installed MariaDB on your Fedora 38 system, it is important to take steps to secure it. Here are some best practices for securing your MariaDB installation:

  • Change the root user password

The first step is to change the password for the root user. By default, MariaDB uses a blank password for the root user, which is a significant security risk. To change the root password, you can run the following command:

sudo mysql_secure_installation

This command will prompt you for a new password and will also perform some other security-related tasks.

  • Create a new user with limited privileges

Instead of using the root user for all database operations, it is recommended that you create a new user account with limited privileges. This will minimize the risk of accidental or intentional damage to your database. To create a new user, run the following commands:

$ sudo mysql -u root -p
MariaDB [(none)]> CREATE USER 'newuser'@'localhost' IDENTIFIED BY 'your-strong-password';
MariaDB [(none)]> GRANT ALL PRIVILEGES ON mydatabase.* TO 'newuser'@'localhost';
MariaDB [(none)]> FLUSH PRIVILEGES;

Replace newuser and password with your desired username and password, respectively.

  • Disable remote root login

Remote root login is a significant security risk, as it allows an attacker to gain full access to your database. You can disable remote root login by editing the MariaDB configuration file at /etc/my.cnf or /etc/mysql/my.cnf. Add the following line under the [mysqld] section:

skip-networking

This will disable MariaDB from listening on any network interface. Restart the MariaDB service for the changes to take effect.

  • Enable MariaDB logging

Enabling MariaDB logging is a good practice for auditing and troubleshooting purposes. You can enable logging by editing the MariaDB configuration file at /etc/my.cnf or /etc/mysql/my.cnf. Add the following lines under the [mysqld] section:

general_log_file = /var/log/mysql/mysql.log
general_log      = 1

This will enable the general query log, which logs all SQL statements received from clients.

Step 4. Firewall Configuration

By default, Fedora 38 has a firewall enabled. You will need to configure your firewall to allow incoming traffic on the MariaDB default port (3306). Use the following command to add the required rule:

sudo firewall-cmd --add-service=mysql --permanent
sudo firewall-cmd --reload

Congratulations! You have successfully installed MariaDB. Thanks for using this tutorial for installing the MariaDB database on your Fedora 38 system. For additional help 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

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