In this tutorial, we will show you how to install MySQL on Fedora 35. For those of you who didn’t know, MySQL is an open-source relational database management system. It’s one of the popular relational management systems. MySQL comes with the following commercial products:
- MySQL Standard Edition.
- MySQL Enterprise Edition.
- MySQL Cluster Carrier Grade Edition.
All these editions come with a price tag and are mostly suitable for commercial use. We will use the MySQL Community Edition, which is available for free usage under the GPL license for this guide.
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 through the step-by-step installation of the MySQL server on a Fedora 35.
Prerequisites
- A server running one of the following operating systems: Fedora 35 or Fedora 34.
- It’s recommended that you use a fresh OS install to prevent any potential issues
- A
non-root sudo user
or access to theroot user
. We recommend acting as anon-root sudo user
, however, as you can harm your system if you’re not careful when acting as the root.
Install MySQL on Fedora 35
Step 1. Before proceeding, update your Fedora operating system to make sure all existing packages are up to date. Use this command to update the server packages:
sudo dnf upgrade sudo dnf update
Step 2. Installing MySQL on Fedora 35.
By default, MySQL is available on Fedora 35 base repository. Then we can install the MySQL server with the following command:
sudo dnf install community-mysql-server
After installation is complete we need to start the MySQL server to start operating. We do that with the following command below:
sudo systemctl start mysqld sudo systemctl enable mysqld sudo systemctl status mysqld
Let us check the MySQL version with this command:
mysql -V
Step 3. Securing MySQL installation.
By default, MySQL is not hardened. You can secure MySQL using the mysql_secure_installation
script. you should read and below each step carefully which will set a root password, remove anonymous users, disallow remote root login, and remove the test database and access to secure MySQL:
mysql_secure_installation
Output:
Securing the MySQL server deployment. Enter password for user root: The existing password for the user account root has expired. Please set a new password. New password: Re-enter new password: The 'validate_password' component is installed on the server. The subsequent steps will run with the existing configuration of the component. Using existing password for root. Estimated strength of the password: 100 Change the password for root ? ((Press y|Y for Yes, any other key for No) : y New password: Re-enter new password: Estimated strength of the password: 100 Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y By default, a MySQL installation has an anonymous user, allowing anyone to log into MySQL 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? (Press y|Y for Yes, any other key for No) : y 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? (Press y|Y for Yes, any other key for No) : y Success. By default, MySQL 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? (Press y|Y for Yes, any other key for No) : y - 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? (Press y|Y for Yes, any other key for No) : y Success. All done!
All done. You can now connect to the MySQL server using the command line. The following command will connect MySQL running on the localhost as the root user:
mysql -u root -p
Step 4. Configure Firewall.
Now we allow for remote connections, allow port 3306 on the firewall:
sudo firewall-cmd --add-service=mysql --permanent sudo firewall-cmd --reload
Congratulations! You have successfully installed MySQL. Thanks for using this tutorial for installing the MySQL database on your Fedora 35 system. For additional help or useful information, we recommend you check the official MySQL website.