How to Install MySQL 8 in Fedora 39 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 39, Fedora 38, and Fedora 37.

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.

Hey TecMint readers,

Exciting news! Every month, our top blog commenters will have the chance to win fantastic rewards, like free Linux eBooks such as RHCE, RHCSA, LFCS, Learn Linux, and Awk, each worth $20!

Learn more about the contest and stand a chance to win by sharing your thoughts below!

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.

7 Comments

Leave a Reply
  1. I have done the dnf update, and then when installing with sudo dnf install community-mysql-server -y it gives the following error:

    Error:
    Problema: problem with installed package mariadb-server-utils-3:10.5.22-1.fc38.x86_64
    – package mariadb-server-utils-3:10.5.22-1.fc38.x86_64 from @System conflicts with community-mysql-server provided by community-mysql-server-8.0.32-1.fc38.x86_64 from fedora
    – package mariadb-server-utils-3:10.5.18-1.fc38.x86_64 from fedora conflicts with community-mysql-server provided by community-mysql-server-8.0.32-1.fc38.x86_64 from fedora
    – package mariadb-server-utils-3:10.5.22-1.fc38.x86_64 from updates conflicts with community-mysql-server provided by community-mysql-server-8.0.32-1.fc38.x86_64 from fedora
    – conflicting requests
    – package mariadb-server-utils-3:10.5.22-1.fc38.x86_64 from @System conflicts with community-mysql-server provided by community-mysql-server-8.0.34-2.fc38.x86_64 from updates
    – package mariadb-server-utils-3:10.5.18-1.fc38.x86_64 from fedora conflicts with community-mysql-server provided by community-mysql-server-8.0.34-2.fc38.x86_64 from updates
    – package mariadb-server-utils-3:10.5.22-1.fc38.x86_64 from updates conflicts with community-mysql-server provided by community-mysql-server-8.0.34-2.fc38.x86_64 from updates
    (pruebe a añadir ‘–allowerasing’ a la línea de comandos para reemplazar los paquetes que producen conflictos o ‘–skip-broken’ para descartar los paquetes que no se pueden instalar)
    

    The article does NOT indicate the use case when MaríaDB has been installed, nor what to do to uninstall it.

    Reply
    • @Federico,

      It seems you’re encountering a package conflict issue between the mariadb-server-utils package version 10.5.22-1.fc38.x86_64 and the community-mysql-server package, which is version 8.0.32-1.fc38.x86_64 in your Fedora system.

      To fix the package conflict error between mariadb-server-utils and community-mysql-server, you’ll need to make a decision on which database server you want to use (MariaDB or MySQL) and resolve the conflict accordingly.

      If you want to keep MariaDB and remove MySQL (community-mysql-server), you can run the following command:

      sudo dnf remove community-mysql-server
      

      If you want to keep MySQL and remove MariaDB (mariadb-server-utils), you can run:

      sudo dnf remove mariadb-server-utils
      

      After removing the unwanted database server, you can then update or install the chosen one. For example, if you decided to use MariaDB, you can update it with:

      sudo dnf update mariadb-server-utils
      

      If you decided to use MySQL, you can update it with:

      sudo dnf update community-mysql-server
      

      Finally, verify that the chosen database server is installed and running as expected.

      sudo systemctl status mariadb    # for MariaDB
      OR
      sudo systemctl status mysqld     # for MySQL
      

      Remember to back up any important data before making these changes, as altering your database server could affect your system’s functionality.

      Reply
  2. 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.