FedoraRHEL Based

How To Install MariaDB on Fedora 41

Install MariaDB on Fedora 41

MariaDB has become an essential component in the world of open-source relational database management systems. As a fork of MySQL, MariaDB offers enhanced features, improved performance, and greater compatibility with various Linux distributions. For Fedora 41 users, installing MariaDB can significantly boost their database management capabilities.

In this comprehensive guide, we’ll walk you through the process of installing MariaDB on Fedora 41, from prerequisites to advanced configuration. Whether you’re a seasoned system administrator or a curious beginner, this article will provide you with the knowledge and tools to successfully set up and manage MariaDB on your Fedora 41 system.

Prerequisites

Before diving into the installation process, it’s crucial to ensure your system meets the necessary requirements and is properly prepared. Here’s what you need to consider:

System Requirements

  • A Fedora 41 system (desktop or server edition)
  • At least 1GB of RAM (2GB or more recommended for optimal performance)
  • Sufficient disk space (at least 5GB free space)
  • A stable internet connection for downloading packages

Necessary Permissions

To install and configure MariaDB, you’ll need root or sudo access on your Fedora 41 system. If you’re not logged in as the root user, make sure your account has sudo privileges.

Updating Fedora 41 System

Before proceeding with the installation, it’s always a good practice to update your system. Open a terminal and run the following command:

sudo dnf update -y

This command will update all installed packages to their latest versions, ensuring compatibility and security.

Installing MariaDB on Fedora 41

Now that your system is prepared, let’s proceed with the installation of MariaDB on Fedora 41.

Using DNF Package Manager

Fedora uses the DNF (Dandified Yum) package manager, which makes installing MariaDB a straightforward process. Follow these steps:

  1. Open a terminal window.
  2. Run the following command to install MariaDB server and client:
sudo dnf install mariadb-server mariadb -y

This command will download and install the MariaDB server and client packages along with their dependencies.

Verifying Installation

After the installation is complete, you can verify it by checking the installed version of MariaDB. Run the following command:

mariadb --version

This should display the version information of the installed MariaDB package.

Starting MariaDB Service

Once installed, you need to start the MariaDB service. Use the following commands:

sudo systemctl start mariadb
sudo systemctl enable mariadb

The first command starts the MariaDB service, while the second enables it to start automatically on system boot.

Configuring MariaDB

After installation, it’s crucial to configure MariaDB properly to ensure security and optimal performance.

Running Initial Security Script

MariaDB provides a security script that helps you improve the security of your installation. Run the following command:

sudo mysql_secure_installation

This script will guide you through several security-related questions. Here’s what you should do:

  1. When prompted for the root password, press Enter (as it’s not set yet).
  2. Type ‘Y’ to set a root password, then enter and confirm your chosen password.
  3. Answer ‘Y’ to remove anonymous users.
  4. Answer ‘Y’ to disallow root login remotely.
  5. Answer ‘Y’ to remove the test database.
  6. Answer ‘Y’ to reload privilege tables.

Setting Root Password

If you didn’t set a root password during the security script, or if you want to change it, you can do so with the following commands:

sudo mariadb
ALTER USER 'root'@'localhost' IDENTIFIED BY 'your_new_password';
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_new_password‘ with your desired password.

Removing Anonymous Users and Test Database

If you skipped these steps in the security script, you can manually remove anonymous users and the test database:

sudo mariadb
DELETE FROM mysql.user WHERE User='';
DROP DATABASE IF EXISTS test;
FLUSH PRIVILEGES;
EXIT;

Creating a Database and User

Now that MariaDB is installed and secured, let’s create a database and user for your applications.

Logging into MariaDB

To log into MariaDB, use the following command:

mariadb -u root -p

Enter the root password when prompted.

Creating a New Database

Once logged in, create a new database with this command:

CREATE DATABASE your_database_name;

Replace ‘your_database_name’ with your desired database name.

Creating a New User and Granting Privileges

Create a new user and grant them privileges on the new database:

CREATE USER 'your_username'@'localhost' IDENTIFIED BY 'your_password';
GRANT ALL PRIVILEGES ON your_database_name.* TO 'your_username'@'localhost';
FLUSH PRIVILEGES;
EXIT;

Replace ‘your_username‘, ‘your_password‘, and ‘your_database_name‘ with your chosen values.

Basic MariaDB Management

Understanding how to manage your MariaDB service is crucial for maintaining a healthy database system.

Starting and Stopping MariaDB Service

To start the MariaDB service:

sudo systemctl start mariadb

To stop the MariaDB service:

sudo systemctl stop mariadb

Checking MariaDB Status

To check the status of your MariaDB service:

sudo systemctl status mariadb

This command will display whether the service is active, stopped, or encountering any issues.

Enabling MariaDB to Start on Boot

To ensure MariaDB starts automatically when your system boots:

sudo systemctl enable mariadb

Optimizing MariaDB Performance

Optimizing your MariaDB installation can significantly improve its performance.

Adjusting Configuration File

The main configuration file for MariaDB is located at /etc/my.cnf.d/mariadb-server.cnf. You can edit this file to adjust various settings:

sudo nano /etc/my.cnf.d/mariadb-server.cnf

Tuning Key Parameters

Some important parameters to consider tuning include:

  • innodb_buffer_pool_size: Set this to about 70-80% of your total RAM for dedicated database servers.
  • max_connections: Adjust based on your expected number of concurrent connections.
  • query_cache_size: Enable and set an appropriate size if you have many repeated queries.

Using mysqltuner Script

The mysqltuner script can provide valuable insights into your MariaDB performance. Install and run it with:

sudo dnf install mysqltuner
mysqltuner

Review the recommendations provided by mysqltuner and adjust your configuration accordingly.

Securing MariaDB

Enhancing the security of your MariaDB installation is crucial for protecting your data.

Implementing Firewall Rules

If you’re using firewalld on Fedora 41, you can allow MariaDB through the firewall with:

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

Enabling SSL/TLS Encryption

To enable SSL/TLS encryption for MariaDB connections:

  1. Generate SSL certificates.
  2. Configure MariaDB to use SSL in the configuration file.
  3. Restart the MariaDB service.

Regular Security Audits

Regularly review user privileges, remove unnecessary accounts, and keep your MariaDB installation updated to maintain a secure environment.

Troubleshooting Common Issues

Even with careful installation and configuration, you may encounter some issues. Here are solutions to common problems:

Connection Problems

If you’re having trouble connecting to MariaDB:

  • Check if the MariaDB service is running.
  • Verify your firewall settings.
  • Ensure you’re using the correct username and password.

Permission Errors

If you encounter permission errors:

  • Check the user privileges for the database in question.
  • Verify that the MariaDB data directory has the correct permissions.

Performance Issues

For performance-related problems:

  • Review your MariaDB configuration and adjust parameters as needed.
  • Analyze slow queries using the slow query log.
  • Consider adding appropriate indexes to your tables.

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

r00t is an experienced Linux enthusiast and technical writer with a passion for open-source software. With years of hands-on experience in various Linux distributions, r00t has developed a deep understanding of the Linux ecosystem and its powerful tools. He holds certifications in SCE and has contributed to several open-source projects. r00t is dedicated to sharing her knowledge and expertise through well-researched and informative articles, helping others navigate the world of Linux with confidence.
Back to top button