Edited 4 weeks ago by ExtremeHow Editorial Team
FedoraMariaDBDatabaseInstallationConfigurationSoftwareCommand LineTerminalSetupSystem Administration
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.
Before you begin the installation process, make sure you have the following:
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.
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.
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.
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:
Y
and press Enter to set a strong password for the MariaDB root user.Y
for better security.Y
to prevent remote root access.Y
Y
to apply the changes.Once the security script has completed execution, your MariaDB installation will be significantly more secure.
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.
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:
sample_db
.sample_user
with the password secure_password
.sample_db
database.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:
sample_db
to use.example_table
with columns id
, name
, and email
.example_table
.example_table
to make sure the record is displayed correctly.Below are some common problems and their solutions:
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.
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.
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