How to Install MySQL 8 in Fedora 38 Linux
MySQL is one of the oldest and most reliable open-source relational database management systems which is trusted and used by millions of users on a daily basis.
Since Fedora has recently announced their new version of the flagship distribution, we are going to cover how you can easily install MySQL 8 in Fedora 38, Fedora 37, and Fedora 36.
Throughout this tutorial, we are going to utilize the default Fedora repositories so we can make this installation process as simple as it can be.
Important: MySQL and MariaDB packages provide similar files and will conflict with each other. For this reason, you should only install MySQL or MariaDB but not both.
Installing MySQL in Fedora Linux
Before installing any package to your system, updating your repositories and applying updates (if any) ensures a robust experience. We are going to update repositories by the given dnf command:
$ sudo dnf update
Once the repositories are updated, we can proceed to the installation part. As we are going to utilize the default repository, it saves us from more complex steps. As we want to have the most recent version of MySQL, we are going to use the community version.
To install MySQL, utilize the given command:
$ sudo dnf install community-mysql-server -y
As we are using dnf, it will automatically handle all the dependencies and will give us a hassle-free experience.
Starting MySQL in Fedora Linux
Just installing MySQL won’t get your job done. Before going any further, we are required to enable MySQL service as it will be in an inactive state after installation.
To check the current status of the MySQL service, utilize the given command:
$ systemctl status mysqld
We will be using the following command to start the MySQL service:
$ sudo systemctl start mysqld
Now, let’s cross-check whether we have successfully started MySQL by using the given command:
$ systemctl status mysqld
As you can see, MySQL is running in an active state.
Similarly, if you want to start MySQL at each boot, you can easily do that by using the given command:
$ sudo systemctl enable mysqld
Securing MySQL in Fedora Linux
The default installation of MySQL is weak by modern standards of security and can easily be manipulated by hackers. There are multiple ways to secure your MySQL, but the simplest yet most effective is to use a secure script.
We can easily start the securing script by the following command:
$ sudo mysql_secure_installation
For most users, this script will work fine but if it asks you for the password, you can retrieve a temporary password from mysqld.log at /var/log/ by the given command:
$ sudo grep 'temporary password' /var/log/mysqld.log
The secure script will ask you the following:
- Setting up a root password
- Removing anonymous users
- Disable root access via remote
- Removing test database
- Reloading root privileges
Connecting to MySQL in Fedora Linux
Once we are done with securing the script, we can easily connect to the MySQL server by the given command:
$ sudo mysql -u root -p
Once we are into MySQL, we can list databases by using the following:
mysql> SHOW DATABASES;
Updating MySQL in Fedora Linux
Despite the fact that we have just finished the installation recently, we can utilize the following command to update MySQL products:
$ sudo dnf update mysql-server
This was our take on how you can easily install MySQL 8 on Fedora in the easiest way possible. But if you still have any issues with installation, feel free to ask in the comments section.