MySQL 8.0 delivers a very fast, multithreaded, multi-user, and robust SQL database server. MySQL is a free, open source database management system. It is a popular choice for web applications and is used by some of the largest websites in the world, including Facebook, Twitter, and YouTube. It forms part of the LAMP Stack (Linux, Apache, MySQL, PHP), a software stack that powers web servers.

The MySQL is Dual Licensed. Users can choose to use the MySQL as an Open Source product under the terms of the GNU General Public License (www.gnu.org) or can purchase a standard commercial license from Oracle. See www.mysql.com for more information.

MySQL Database Lifecycle

VersionRelease DateEnd of life
8.008 Apr 201830 Apr 2026
5.709 Oct 201531 Oct 2023
5.601 Feb 201328 Feb 2021
MySQL Database Lifecycle
latest-mysql-8-installation-on-redhat-centos-linux
Latest MySQL-8.0 installation on Linux server

Steps to install MySQL 8.0 on Linux server

Installation of MySQL Database 8.0 on Linux is easy. This tutorial will explain how to install MySQL version 8.0 Community Server edition on a RHEL based Linux server like Red Hat Enterprise Linux, CentOS, Oracle Linux, Rocky Linux and AlmaLinux.

If you want to install MySQL on Ubuntu based servers then please read this article.

Prerequisites:

  • sudo privileges.
  • Stable internet connection.
  • Disable SELinux and Firewall

TL;DR

If you want to install default available MySQL version then run following command:

CentOS, RedHat and Oracle Linux 7
# yum install mysql-server
OR
CentOS, RedHat, Oracle Linux, Rocky Linux and AlmaLinux version 8/9
# dnf install mysql-server

Install latest MySQL 8.0 on CentOS, RedHat, Oracle Linux, Rocky Linux and AlmaLinux:

Steps to install MySQL 8.0 on Red Hat Enterprise Linux, CentOS, Oracle Linux, Rocky Linux and AlmaLinux.

Note : CentOS 7 prefers MariaDB, a fork of MySQL managed by the original MySQL developers and designed as a replacement for MySQL. MariaDB will generally work seamlessly in place of MySQL.

Check your current Operating System version if you are not sure.

# egrep '^(VERSION|NAME)=' /etc/os-release

For CentOS 7 / Red Hat Enterprise Linux 7 / Oracle Linux 7, first remove MariaDB library, It may create dependency issue:

# yum remove mariadb-libs

Now just copy and paste below in terminal to setup MySQL 8.0 yum repo for CentOS 7 / Red Hat Enterprise Linux 7 / Oracle Linux 7:

# tee /etc/yum.repos.d/mysql-community.repo<<EOM
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=https://repo.mysql.com/yum/mysql-8.0-community/el/7/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

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

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

[mysql-cluster-8.0-community]
name=MySQL Cluster 8.0 Community
baseurl=https://repo.mysql.com/yum/mysql-cluster-8.0-community/el/7/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

EOM

Setup MySQL 8.0 yum repo for Red Hat Enterprise Linux 8, CentOS stream 8, Oracle Linux 8, Rocky Linux 8 and AlmaLinux 8.

# tee /etc/yum.repos.d/mysql-community.repo<<EOM
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/8/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

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

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

[mysql-cluster-8.0-community]
name=MySQL Cluster 8.0 Community
baseurl=http://repo.mysql.com/yum/mysql-cluster-8.0-community/el/8/\$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

EOM

Setup MySQL 8.0 yum repo for Red Hat Enterprise Linux 9, CentOS stream 9, Oracle Linux 9, Rocky Linux 9 and AlmaLinux 9.

# tee /etc/yum.repos.d/mysql-community.repo<<EOM
[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/9/\$basearch/
enabled=1
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

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

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

[mysql-cluster-8.0-community]
name=MySQL Cluster 8.0 Community
baseurl=http://repo.mysql.com/yum/mysql-cluster-8.0-community/el/9/\$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql-2022

EOM

Now to install MySQL 8.0, run the following command in terminal:

#  yum install mysql-community-server -y

OR

# dnf install mysql-community-server -y

 Managing the MySQL service

let’s review some basic management commands.

Verify installed version of MySQL:

#  mysql --version

Start the MySQL service:

# systemctl start mysqld.service

Check status of the MySQL service:

# systemctl status mysqld.service

Restart the MySQL service:

# systemctl restart mysqld.service

If you want to stop MySQL service:

# systemctl stop mysqld.service

By default, MySQL service is disabled to start automatically when the server boots. If you want to enable it at startup, run:

# systemctl enable mysqld.service

Re-disable the service to start up at boot:

# systemctl disable mysqld.service

Uninstall MySQL

To completely remove MySQL from a system, you must remove the MySQL applications, the configuration files, and any directories containing data and logs.

WARNING: This process will completely remove MySQL, its configuration, and all databases. This process is not reversible, so ensure that all of your configuration and data is backed up before proceeding.

Stop the MySQL service

# systemctl stop mysqld.service

Remove any MySQL packages that previously installed.

For RHEL / CentOS/ Oracle Linux / Rocky Linux / Amazon Linux

# yum erase $(rpm -qa | grep mysql*)

Remove MySQL databases and log files.

# rm -rf /var/lib/mysql /var/log/mysql /etc/mysql /var/run/mysqld /etc/apparmor.d/abstractions/mysql

Conclusion

Congratulations! We’ve installed latest MySQL 8.0 on RedHat based Linux servers. We hope this 2 minutes stuff helped you and thank you for visiting our website.
Cheers!!!