Saturday, December 28, 2024
Google search engine
HomeData Modelling & AIHow To Install MySQL 8.0 on Fedora 38/37/36/35/34/33

How To Install MySQL 8.0 on Fedora 38/37/36/35/34/33

In this guide, we will cover how to install MySQL 8.0 on Fedora 38/37/36/35/34/33 Server or Workstation. If you have an old version of MySQL Server (e.g 5.7), you may need to do an in-place upgrade or dump all data, upgrade packages and re-import all database data to new MySQL 8.0 installed.

Our recent MySQL 8.0 installation guide was for Ubuntu: How to Install MySQL 8.0 on Ubuntu. The version of MySQL available via Fedora Modular repository is MySQL 5.7.

For a complete LAMP Stack on Fedora, check How to install LAMP Stack on Fedora

One dependency for this setup is an installed and running instance of Fedora Linux distribution. See How to install Fedora on Physical Server / Virtual Environment

Step 1: Add MySQL 8.0 community repository

To install MySQL 8.0 on Fedora, you need to add MySQL 8.0 community repository.

Add MySQL 8.0 repository to Fedora:

### Fedora 38 ###
sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc38-1.noarch.rpm

### Fedora 37 ###
sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc37-1.noarch.rpm

### Fedora 36 ###
sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc36-1.noarch.rpm

### Fedora 35 ###
sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc35-3.noarch.rpm

### Fedora 34 ###
sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc34-3.noarch.rpm

### Fedora 33 ###
sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc33-2.noarch.rpm

### Fedora 32 ###
sudo dnf -y install https://dev.mysql.com/get/mysql80-community-release-fc32-1.noarch.rpm

This will write a repository file to /etc/yum.repos.d/mysql-community.repo

$ cat /etc/yum.repos.d/mysql-community.repo
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/fc/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-connectors-community]
name=MySQL Connectors Community
baseurl=http://repo.mysql.com/yum/mysql-connectors-community/fc/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-community]
name=MySQL Tools Community
baseurl=http://repo.mysql.com/yum/mysql-tools-community/fc/$releasever/$basearch
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql-tools-preview]
name=MySQL Tools Preview
baseurl=http://repo.mysql.com/yum/mysql-tools-preview/fc/$releasever/$basearch
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

Step 2: Install MySQL Server 8.0 on Fedora

Once you have added the repository and confirm to be enabled, proceed to install MySQL 8.0 onto your Fedora by running:

sudo dnf install mysql-community-server

Proceed with the installation process of MySQL 8.0 on Fedora:

Transaction Summary
======================================================================================================================================================================================================
Install  69 Packages

Total download size: 56 M
Installed size: 324 M
Is this ok [y/N]: y

Also accept the importation of GPG keys when requested.

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                                  67 MB/s |  50 MB     00:00
MySQL 8.0 Community Server                                                                                                                                            3.0 MB/s | 3.1 kB     00:00
Importing GPG key 0x3A79BD29:
 Userid     : "MySQL Release Engineering <[email protected]>"
 Fingerprint: 859B E8D7 C586 F538 430B 19C2 467B 942D 3A79 BD29
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022
Is this ok [y/N]: y

After installation, the package info can be seen from:

$ rpm -qi mysql-community-server
ion     : 8.0.33
Release     : 10.fc38
Architecture: x86_64
Install Date: Mon 24 Apr 2023 08:15:17 PM UTC
Group       : Unspecified
Size        : 116888827
License     : Copyright (c) 2000, 2023, Oracle and/or its affiliates. Under GPLv2 license as shown in the Description field.
Signature   : RSA/SHA256, Tue 21 Mar 2023 03:21:42 AM UTC, Key ID 467b942d3a79bd29
Source RPM  : mysql-community-8.0.33-10.fc38.src.rpm
Build Date  : Mon 20 Mar 2023 08:43:25 AM UTC
Build Host  : pb2-fedora38-02
Packager    : MySQL Release Engineering <[email protected]>
Vendor      : Oracle and/or its affiliates
URL         : http://www.mysql.com/
....

Step 3: Configure MySQL server on Fedora

After installation of MySQL 8.0 on Fedora, you need to do initial configuration to secure it.

1. Start and enable mysqld service:

sudo systemctl start mysqld.service
sudo systemctl enable mysqld.service

2. Copy the generated random password for the root user

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

Take note the printed password:

A temporary password is generated for root@localhost: 1ph/axo>vJe;

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. Then configure your MySQL 8.0 installation like below:

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
Success.

Disallow root login remotely? : Yes
Success.

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

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

All done!

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

$ sudo mysql -u root -p
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.33

Copyright (c) 2000, 2023, Oracle and/or its affiliates.

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

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

mysql> SELECT version();
+-----------+
| version() |
+-----------+
| 8.0.33    |
+-----------+
1 row in set (0.00 sec)

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)

mysql> FLUSH PRIVILEGES;
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
Bye

Step 4: Configure Firewall for remote connections

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="10.1.1.0/24" accept'

Thanks for installing MySQL 8.0 on Fedora with our guide. Until next time, stay tuned.

Other MySQL articles:

RELATED ARTICLES

Most Popular

Recent Comments