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
Install MySQL in Fedora
Install MySQL in Fedora

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
Check MySQL Status
Check MySQL Status

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
Check MySQL Status in Fedora
Check MySQL Status in Fedora

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
Secure MySQL in Fedora
Secure MySQL in Fedora

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
Connect to MySQL
Connect to MySQL

Once we are into MySQL, we can list databases by using the following:

mysql> SHOW DATABASES;
List MySQL Databases
List MySQL 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
Update MySQL in Fedora
Update MySQL in Fedora

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.

If you read this far, tweet to the author to show them you care. Tweet a thanks
Sagar Sharma
I'm a software engineer trying my best to bring open-source software to a general audience. Being a Linux author solves my purpose.

Each tutorial at TecMint is created by a team of experienced Linux system administrators so that it meets our high-quality standards.

Join the TecMint Weekly Newsletter (More Than 156,129 Linux Enthusiasts Have Subscribed)
Was this article helpful? Please add a comment or buy me a coffee to show your appreciation.

5 thoughts on “How to Install MySQL 8 in Fedora 38 Linux”

  1. Installing is not an issue, but actually connecting to a MySQL database is a different story, nor matter what you do, you will always get “Access denied for user@localhost using password (YES)“…

    Reply
    • @Andre,

      You need to allow user to access the database on MySQL with these commands.

      CREATE USER 'golden'@'localhost' IDENTIFIED BY 'password';
      GRANT ALL PRIVILEGES ON * . * TO 'golden'@'localhost';
      FLUSH PRIVILEGES;
      
      Reply

Got something to say? Join the discussion.

Thank you for taking the time to share your thoughts with us. We appreciate your decision to leave a comment and value your contribution to the discussion. It's important to note that we moderate all comments in accordance with our comment policy to ensure a respectful and constructive conversation.

Rest assured that your email address will remain private and will not be published or shared with anyone. We prioritize the privacy and security of our users.