WindowsMacSoftwareSettingsSecurityProductivityLinuxAndroidPerformanceConfigurationApple All

How to Install and Configure MariaDB on Fedora

Edited 4 weeks ago by ExtremeHow Editorial Team

FedoraMariaDBDatabaseInstallationConfigurationSoftwareCommand LineTerminalSetupSystem Administration

How to Install and Configure MariaDB on Fedora

This content is available in 7 different language

MariaDB is a popular open-source relational database management system (RDBMS) that is a fork of MySQL. Fedora is a Linux-based operating system known for its innovation and use in leading software. Installing and configuring MariaDB on Fedora is a straightforward process, and this guide will walk you through each step in detail. Please follow these instructions carefully to ensure a smooth installation. This document will provide a step-by-step tutorial, including command examples, configuration details, and some common troubleshooting tips.

Prerequisites

Before you begin the installation process, make sure you have the following:

Step 1: Update the system

It is always a good practice to update system packages before installing any new software. This ensures that all dependencies are up-to-date and reduces the risk of facing compatibility issues. Open the terminal and run the following command:

# sudo dnf update

dnf update command downloads and installs the latest updates for all installed packages on your system. Enter the password when prompted. Depending on the number of updates available, this process may take some time to complete.

Step 2: Install MariaDB

After the system is updated, you can start installing MariaDB. Fedora's default repositories include MariaDB, making it easy to install it without adding any additional repositories. Use the following command to install MariaDB:

# sudo dnf install mariadb-server mariadb

This command will install the MariaDB server and the relevant client packages. The package manager may ask for confirmation before proceeding. Type y and press Enter to confirm the installation. The installation process will take a few minutes.

Step 3: Start and enable MariaDB

After the installation is complete, you must start the MariaDB service. You can do this using systemctl command. Additionally, you can enable MariaDB to start automatically on boot. Run the following command:

# sudo systemctl start mariadb # sudo systemctl enable mariadb

The first command starts the MariaDB service, and the second command makes sure that MariaDB starts automatically whenever you boot your system.

Step 4: Secure MariaDB

MariaDB provides a security script to improve the security of your installation. This script helps to remove anonymous users, remotely deny root login, delete the test database, and reload privilege tables. Execute the following command to run the security script:

# sudo mysql_secure_installation

You will be asked a number of questions. Here are some answers you should give:

  1. Enter the current password for root. Press Enter if this is your first time setting it, as there is no password yet.
  2. Set root password? Type Y and press Enter to set a strong password for the MariaDB root user.
  3. Want to remove anonymous users? Type Y for better security.
  4. Do not allow root login remotely? Type Y to prevent remote root access.
  5. Delete the test database and access to it? Type Y
  6. Reload privilege tables now? Type Y to apply the changes.

Once the security script has completed execution, your MariaDB installation will be significantly more secure.

Step 5: Access MariaDB

You can now access the MariaDB shell as the root user using the following command:

# mysql -u root -p

After you enter the root password you set earlier, you will be logged into the MariaDB shell. In this environment, you can execute SQL queries, create databases, and perform administrative tasks.

Step 6: Create the database and user

MariaDB allows you to create multiple databases and users. Let's create a sample database and a user that can access this database. Follow the SQL command below:

CREATE DATABASE sample_db; CREATE USER 'sample_user'@'localhost' IDENTIFIED BY 'secure_password'; GRANT ALL PRIVILEGES ON sample_db.* TO 'sample_user'@'localhost'; FLUSH PRIVILEGES;

This series of commands will do the following:

Step 7: Test the MariaDB installation

After creating the database and user, you can test your MariaDB installation by executing simple SQL commands. For example, switch to the sample_db database and create a table using the command below:

USE sample_db; CREATE TABLE example_table ( id INT AUTO_INCREMENT PRIMARY KEY, name VARCHAR(100), email VARCHAR(100) ); INSERT INTO example_table (name, email) VALUES ('John Doe', 'john.doe@example.com'); SELECT * FROM example_table;

The commands perform the following functions:

Troubleshooting common problems

Below are some common problems and their solutions:

Service failed to start

If the MariaDB service fails to start, check the status of the service as follows:

# sudo systemctl status mariadb

Look for error messages or warnings in the command output. Also, check the MariaDB log files in the /var/log/ directory for more information.

Access denied for user

If you receive an "Access Denied for User" error, make sure you are using the correct username and password. Additionally, confirm that the user has been granted the necessary privileges on the desired database.

Conclusion

Installing and configuring MariaDB on Fedora is an essential skill for database administrators and developers. By following the instructions detailed in this guide, you should now have a working MariaDB installation on your Fedora system. Take advantage of this powerful RDBMS by creating and managing your databases efficiently.

In addition to these steps, always refer to the official MariaDB documentation for more advanced configuration and security practices to further improve your setup.

If you find anything wrong with the article content, you can


Comments