How to Install MySQL 8 on Fedora

MySQL is one of the most popular open source database management systems. In this tutorial, we will show you how to install MySQL 8 on Fedora.

Posted on

MySQL 8 is the latest major version upgrade of MySQL. It comes with many new features and improvements such as better performance, new SQL functions, new JSON data type support, atomic DDL statements, invisible indexes, etc.

In this tutorial, we will show you how to install MySQL 8 on Fedora from the default Fedora repositories.

Prerequisites

Before you install MySQL, you need to have the following prerequisites:

  • Fedora workstation installed
  • Non-root user with sudo privileges
  • Internet connection

Step 1 - Enable MySQL Repository

First enable the MySQL 8.0 community repository:

sudo dnf config-manager --set-enabled mysql80-community

This will enable the MySQL 8.0 RPM packages.

Step 2 - Install MySQL

Now you can install MySQL by running:

sudo dnf install mysql-server

This will install MySQL 8.0 on your Fedora system.

Step 3 - Start MySQL Service

After install, start the MySQL service:

sudo systemctl start mysqld

Step 4 - Secure MySQL Server

It is recommended to run the mysql_secure_installation script to improve MySQL security:

sudo mysql_secure_installation

This will set the root password, remove anonymous user accounts, disable root logins outside localhost etc.

Step 5 - Create a Dedicated MySQL User

It’s best practice to create a dedicated user instead of using root:

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

Step 6 - Test MySQL

Connect to MySQL shell with the new user:

mysql -u myuser -p

Run a test command:

SHOW DATABASES;

Step 7 - Create Sample Database and Table

Create a test database and table:

CREATE DATABASE mytestdb;
USE mytestdb;

CREATE TABLE users (
  id INT AUTO_INCREMENT PRIMARY KEY,
  name VARCHAR(50),
  email VARCHAR(50)
);

MySQL 8 is now ready to use!

Conclusion

We have demonstrated how to install MySQL 8 on Fedora from the default repositories. You can now start developing applications using MySQL on your Fedora desktop or server.

If you want to learn more about MySQL, please use our MySQL tutorials and MySQL Reference.