How to Install MySQL 8 on CentOS Stream 9

Pre-requisites:

A system with CentOS Stream 9 installed and running
Access to a terminal or command line
Root or sudo privileges

First update your system

dnf update -y

Add the MySQL Repository

dnf install -y http://dev.mysql.com/get/mysql80-community-release-el9-1.noarch.rpm

Install MySQL using the DNF package manager after the repository has been added

dnf install -y mysql-community-server

If you receive the following messages

Error: GPG check failed

GPG Keys are configured as: file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

Workaround: install GPG key manually. You'll need to load the key that is not yet expired directly from a url

rpm --import http://repo.mysql.com/RPM-GPG-KEY-mysql-2023

The my.cnf is the configuration file for MySQL databases

find '/' -name "my.cnf"

The -name option searches for files with a specific name
The root filesystem is represented by a forward slash ("/")

Start the MySQL service

systemctl start mysqld.service

Enable MySQL to start on boot

systemctl enable mysqld

Secure MySQL Installation

mysql_secure_installation

Follow the prompts

Testing MySQL

mysql -u root -p

Enter the password you set. If you're greeted by the prompt, then your mysql installation is successfully installed.

You can show your MySQL version with the following command:

mysql -V

You can check the status of the MySQL server with the following command:

systemctl status mysqld

Port 3306 is MySQL's default port.

MySQL writes a log file. Its path is /var/log/mysqld.log, defined in the log-error config variable.

Linux supports a number of different solutions for installing MySQL.

To see a list of options provided by mysql, invoke it with the --help option:

mysql --help

Remember to keep MySQL up to date for the latest security features, performance enhancements, and bug fixes.

For more information:

http://dev.mysql.com/doc/refman/8.0/en/linux-installation.html

http://dev.mysql.com/doc/refman/8.0/en/checking-rpm-signature.html

http://stackoverflow.com/questions/71239450/gpg-keys-issue-while-installing-mysql-community-server

Learn

Related articles

Getting Started with React

In this guide, we will cover the basics of setting up a local development environment, starting a simple React project, and the basics of how it works.

How to Create Bash Aliases

This tutorial demonstrates how to use the alias command to create personalized shortcuts, which can help you save time and feel less frustrated.

Using Git for PHP Development

This guide walks through the fundamentals of Git. In this tutorial, we will show you Git commands. For Linux you can use the built-in terminal.

How to Connect to MySQL with Laravel

In this guide, you will learn how to connect your Laravel application to your MySQL database.

How do you change the default SSH Port on CentOS Stream 9?

Changing the default SSH port adds an extra layer of security by reducing the risk of your password being cracked from a brute force attack.

What is Inheritance in PHP?

In this tutorial we will explain inheritance in PHP, a mechanism that allows a child class to inherit properties and behaviors from a parent class.