You can support us by downloading this article as PDF from the Link below. Download the guide as PDF

Question: How can I install MySQL 5.7 on Fedora 31/30/29?. MySQL is the most robust production-grade RDBMS based on Structured Query Language (SQL). Its development is backed by Oracle Corporation. With its proven reliability, performance, and ease-of-use, MySQL has become the leading database choice for web-based applications.

Some big companies using MySQL includes Facebook, Twitter, YouTube, and many others. MySQL has a huge user community behind it, so you can always get help when you need one.

Step 1: Install MySQL 5.7 on Fedora 31/30/29

The packages for MySQL 5.7 are available on Oracle upstream repositories for Fedora. Add the repository using the following commands – specific to each distribution.

Add MySQL 8.0 repository to Fedora 31

sudo dnf -y install

For Fedora 30:

sudo dnf -y install

For Fedora 29:

sudo dnf -y install

The commands above will add repository contents to the file /etc/yum.repos.d/mysql-community.repo.

The default package mysql-community-server installed is for MySQL 8. To install MySQL 5.7 on Fedora 31/30/29, first enable channel for MySQL 5.7.

sudo dnf --disablerepo=mysql80-community --enablerepo=mysql57-community install mysql-community-server

Press “y” key to start the installation.

Transaction Summary
Install  49 Packages
Total download size: 214 M
Installed size: 970 M
Is this ok [y/N]: y

Also Agree to add GPG key.

Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <[email protected]>"
 Fingerprint: A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y

To view installed package specific details, use:

$ rpm -qi mysql-community-server
 Name        : mysql-community-server
 Version     : 5.7.26
 Release     : 1.fc29
 Architecture: x86_64
 Install Date: Wed 08 May 2019 06:56:53 PM CEST
 Group       : Applications/Databases
 Size        : 766402082
 License     : Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved. Under GPLv2 license as shown in the Description field.
 Signature   : DSA/SHA1, Mon 15 Apr 2019 11:21:42 AM CEST, Key ID 8c718d3b5072e1f5
 Source RPM  : mysql-community-5.7.26-1.fc29.src.rpm
 Build Date  : Sat 13 Apr 2019 04:54:54 PM CEST
 Build Host  :
 Relocations : (not relocatable)
 Packager    : MySQL Release Engineering [email protected]
 Vendor      : Oracle and/or its affiliates
 URL         :
 Summary     : A very fast and reliable SQL database server

Step 2: Configure MySQL 5.7 on Fedora 31/30/29.

2.1 – After the installation, start mysqld service.

sudo systemctl enable --now mysqld.service

2.2 – Copy the generated random password for the root user

grep 'A temporary password' /var/log/mysqld.log |tail -1

Take note of the printed password:

2019-05-08T16:59:02.412078Z 1 [Note] A temporary password is generated for [email protected]: -gv9kyqud*,U

2.3 – Start MySQL Secure Installation to change the root password, Disallow root login remotely, remove anonymous users and remove test database.

$ sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root:

Authenticate with your generated temporary password. This will ask you to set a new password for the root user.

Change the password for root ? ((Press y|Y for Yes, any other key for No) : Yes

New password: 
Re-enter new password: 

Estimated strength of the password: 100 
Do you wish to continue with the password provided?: Yes

Remove anonymous users?: Yes

Disallow root login remotely? : Yes

Remove test database and access to it? : Yes
 - Dropping test database...
 - Removing privileges on test database...

Reload privilege tables now? (Press y|Y for Yes) : Yes

All done!

You can use online password generator to get a complex password.

2.4 – Connect to MySQL Database as root user and create a test database.

$ mysql -u root -p
Enter password: <Enter Root Password>
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 5.7.26 MySQL Community Server (GPL)

Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective

Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.


2.5 – Create a test database and user:

mysql> CREATE DATABASE test_db;
Query OK, 1 row affected (0.09 sec)

mysql> CREATE USER 'test_user'@'localhost' IDENTIFIED BY "Strong34S;#";
Query OK, 0 rows affected (0.04 sec)

mysql> GRANT ALL PRIVILEGES ON test_db.* TO 'test_user'@'localhost';
Query OK, 0 rows affected (0.02 sec)

Query OK, 0 rows affected (0.02 sec)

This test database and user can be dropped by running:

mysql> DROP DATABASE test_db;
Query OK, 0 rows affected (0.14 sec)

mysql> DROP USER 'test_user'@'localhost';
Query OK, 0 rows affected (0.11 sec)

mysql> show databases;
| Database           |
| information_schema |
| mysql              |
| performance_schema |
| sys                |
4 rows in set (0.01 sec)

mysql> QUIT

Step 3: Configure Firewall

To allow for remote connections, allow port 3306 on the firewall

sudo firewall-cmd --add-service=mysql --permanent
sudo firewall-cmd --reload

You can also limit access from trusted networks

sudo firewall-cmd --permanent --add-rich-rule 'rule family="ipv4" \
service name="mysql" source address="" accept'

Thanks for installing MySQL 5.7 on Fedora 31/30/29 using our guide. Until next time, stay connected.

Other MySQL articles:

How To Install MySQL 8 on Fedora

How to convert all MySQL tables from MyISAM into InnoDB Storage engine

How to solve “MySQL server is running with the –secure-file-priv” Error

How to find database sizes in MySQL/MariaDB Database Server

You can support us by downloading this article as PDF from the Link below. Download the guide as PDF