MariaDB is one of the most popular open-source databases next to its originator MySQL. The original creators of MySQL developed MariaDB in response to fears that MySQL would suddenly become a paid service due to Oracle acquiring it in 2010. With its history of doing similar tactics, the developers behind MariaDB have promised to keep it open source and free from such fears as what has happened to MySQL.
MariaDB has become just as popular as MySQL with developers, with advanced clustering with Galera Cluster 4, faster cache/indexes, storage engines, and features/extensions that you won’t find in MySQL.
In the following tutorial, you will learn how to install MariaDB 10.7 on Fedora 35 Workstation or Server.
Table of Contents
- Recommended OS: Fedora Linux 35.
- User account: A user account with sudo or root access.
Update Operating System
Update your Fedora operating system to make sure all existing packages are up to date:
sudo dnf upgrade --refresh -y
The tutorial will be using the sudo command and assuming you have sudo status.
To verify sudo status on your account:
Example output showing sudo status:
[joshua@fedora ~]$ sudo whoami root
To set up an existing or new sudo account, visit our tutorial on Adding a User to Sudoers on Fedora.
To use the root account, use the following command with the root password to log in.
Install Dependency Required
Before you proceed with the installation, run the following command to install or check that the package dnf-plugins-core is installed on your Fedora desktop.
sudo dnf install dnf-plugins-core -y
By default, this should be installed.
Install MariaDB 10.7 on Fedora
By default, MariaDB 10.7 is featured in Fedora 35’s repository. However, you need to enable it. To do this, first print out what versions of MariaDB are available.
sudo dnf module list mariadb
As above, the default repository is 10.5. However, 10.6 and 10.7 are available. To enable version 10.7 MariaDB series, use the following command.
sudo dnf module enable mariadb:10.7
Type Y and press the ENTER KEY to proceed and enable the change of module streams.
Next, proceed to install MariaDB in your terminal by executing the following.
sudo dnf install mariadb mariadb-client
Type Y and press the ENTER KEY to proceed and complete the installation.
Confirm the installation of MariaDB by checking the version and build:
mariadb Ver 15.1 Distrib 10.7.1-MariaDB, for Linux (x86_64) using EditLine wrapper
Check MariaDB 10.7 Service Status
By default, MariaDB is deactivated and not enabled on system boot. To start and activate MariaDB, use the following command.
sudo systemctl enable mariadb --now
Next, verify the service status.
systemctl status mariadb
By default, you will find MariaDB status to be activated. If not, start MariaDB, use the following command:
sudo systemctl start mariadb
To stop MariaDB:
sudo systemctl stop mariadb
To enable MariaDB on system startup:
sudo systemctl enable mariadb
To disable MariaDB on system startup:
sudo systemctl disable mariadb
To restart the MariaDB service:
sudo systemctl restart mariadb
Secure MariaDB 10.7 with Security Script
When installing MariaDB fresh, default settings are considered weak by most standards and cause concern for potentially allowing intrusion or exploiting hackers. A solution is to run the installation security script with the MariaDB installation.
First, use the following command to launch the (mysql_secure_installation):
Next, follow below:
- Setting the password for root accounts.
- Removing root accounts that are accessible from outside the local host.
- Removing anonymous-user accounts.
- Removing the test database, which by default can be accessed by anonymous users.
Note, you use (Y) to remove everything.
[joshua@fedora ~]$ sudo mariadb-secure-installation NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MariaDB SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY! In order to log into MariaDB to secure it, we'll need the current password for the root user. If you've just installed MariaDB, and haven't set the root password yet, you should just press enter here. Enter current password for root (enter for none): OK, successfully used password, moving on... Setting the root password or using the unix_socket ensures that nobody can log into the MariaDB root user without the proper authorisation. You already have your root account protected, so you can safely answer 'n'. Switch to unix_socket authentication [Y/n] Y <---- Type Y then press the ENTER KEY. Enabled successfully! Reloading privilege tables.. ... Success! You already have your root account protected, so you can safely answer 'n'. Change the root password? [Y/n] Y <---- Type Y then press the ENTER KEY. New password: Re-enter new password: Password updated successfully! Reloading privilege tables.. ... Success! By default, a MariaDB installation has an anonymous user, allowing anyone to log into MariaDB without having to have a user account created for them. This is intended only for testing, and to make the installation go a bit smoother. You should remove them before moving into a production environment. Remove anonymous users? [Y/n] Y <---- Type Y then press the ENTER KEY. ... Success! Normally, root should only be allowed to connect from 'localhost'. This ensures that someone cannot guess at the root password from the network. Disallow root login remotely? [Y/n] Y <---- Type Y then press the ENTER KEY. ... Success! By default, MariaDB comes with a database named 'test' that anyone can access. This is also intended only for testing, and should be removed before moving into a production environment. Remove test database and access to it? [Y/n] Y <---- Type Y then press the ENTER KEY. - Dropping test database... ... Success! - Removing privileges on test database... ... Success! Reloading the privilege tables will ensure that all changes made so far will take effect immediately. Reload privilege tables now? [Y/n] Y <---- Type Y then press the ENTER KEY. ... Success! Cleaning up... All done! If you've completed all of the above steps, your MariaDB installation should now be secure. Thanks for using MariaDB!
Login to MariaDB 10.7 Instance
Now that you have completed the post-installation installation security script, login into your MariaDB database can be done using the following:
sudo mysql -u root -p
You will be prompted to enter the root password that you set in either the installation setup or post-installation security script. Once inside the MySQL service instance, you can execute the following command as a test to see it in operation.
Type the following SHOW DATABASE command:
For those new to MySQL, all commands syntax must end with ;
TO (CREATE) a database, use the following command.
CREATE DATABASE MYDATATEST;
To delete (DROP) a database, use the following command.
DROP DATABASE MYDATATEST;
To exit the terminal, type the following exit command :
How to Remove (Uninstall) MariaDB 10.7
If you no longer wish to use MariaDB and want to remove it in full, execute the following command:
sudo dnf autoremove mariadb mariadb-client -y
Note that this command will remove most of the unused dependencies in the MariaDB installation to help clean up your system.
Note, for users who may want to roll back a version, such as installing MariaDB 10.6 or 10.5, and you will need to reset the module list.
In your terminal, use the following command.
sudo dnf module reset mariadb -y
This will roll back to the default selection of MariaDB on Fedora 35. Install this version, or to choose another, you will use what you did for MariaDB 10.7, but using a different version option.
Example MariaDB 10.6:
sudo dnf module enable mariadb:10.6 -y
Comments and Conclusion
In the tutorial, you have learned how to install the latest MariaDB 10.7 release Fedora 35.
Overall, it would help if you upgraded from the old stable 10.5 as it’s pretty seasoned now compared to 10.6 if you are not moving to 10.7 just yet. There are considerable advantages in performance with upgrading. If you do upgrade, always back up your database before doing so to avoid countless hours of pain and utter frustration in anything to do with database maintenance or upgrades.