Steps to Install MySQL8 on CentOS

In this tutorial, we’ll explain the Steps to Install MySQL8 on CentOS or Amazon Linux using the MySQL Yum Repository.

MySQL Yum repository for Oracle Linux, Red Hat Enterprise Linux, CentOS, and Fedora.

Steps to Install MySQL8 on CentOS or Amazon Linux

Step 1: Install WGET command on Linux

$ sudo yum install wget -y

Step 2: Download MySQL Yum Repository

This is the one-time operation you need to set up on your Linux server. Download link is mentioned below or you can download it from URL.

Download the release package for your specific platform

Red Hat Enterprise Linux 8 / Oracle Linux 8 (Architecture Independent), RPM Package
https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm

Red Hat Enterprise Linux 7 / Oracle Linux 7 (Architecture Independent), RPM Package
https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm

Red Hat Enterprise Linux 6 / Oracle Linux 6 (Architecture Independent), RPM Package
wget https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm

Fedora 31 (Architecture Independent), RPM Package
https://dev.mysql.com/get/mysql80-community-release-fc31-1.noarch.rpm

Fedora 30 (Architecture Independent), RPM Package
https://dev.mysql.com/get/mysql80-community-release-fc30-1.noarch.rpm

Once you download MySQL noarch from above URL from any web browser or download on Linux using wget command.

In this tutorial, we have taken el6 OS (CentOS6), so we have downloaded el6 MySQL noarch as shown below: (for Fedora install use dnf instead of yum)

$ wget https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm

$ sudo yum localinstall mysql80-community-release-el6-3.noarch.rpm
#Sample Output
[root@mysql8 centos]# wget https://dev.mysql.com/get/mysql80-community-release-el6-3.noarch.rpm
[root@mysql8 centos]# ls
mysql80-community-release-el6-3.noarch.rpm
[root@mysql8 centos]#
[root@mysql8 centos]#
[root@mysql8 centos]# sudo yum localinstall mysql80-community-release-el6-3.noarch.rpm
Loaded plugins: fastestmirror, presto
Setting up Local Package Process
Examining mysql80-community-release-el6-3.noarch.rpm: mysql80-community-release-el6-3.noarch
Marking mysql80-community-release-el6-3.noarch.rpm to be installed
Determining fastest mirrors
* base: centos.mirror.snu.edu.in
* extras: centos.mirror.snu.edu.in
* updates: centos.mirror.snu.edu.in
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el6-3 will be installed
--> Finished Dependency Resolution

Dependencies Resolved

================================================================================================
Package Arch Version Repository Size
================================================================================================
Installing:
mysql80-community-release noarch el6-3 /mysql80-community-release-el6-3.noarch 31 k

Transaction Summary
================================================================================================
Install 1 Package(s)

Total size: 31 k
Installed size: 31 k
Is this ok [y/N]: y
Downloading Packages:
Running rpm_check_debug
Running Transaction Test
Transaction Test Succeeded
Running Transaction
Installing : mysql80-community-release-el6-3.noarch 1/1
Verifying : mysql80-community-release-el6-3.noarch 1/1

Installed:
mysql80-community-release.noarch 0:el6-3

Complete!
[root@mysql8 centos]#

Sample MySQL Repository for Linux System

# Enable to use MySQL 5.5
[mysql55-community]
name=MySQL 5.5 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.5-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.6
[mysql56-community]
name=MySQL 5.6 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.6-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

# Enable to use MySQL 5.7
[mysql57-community]
name=MySQL 5.7 Community Server
baseurl=http://repo.mysql.com/yum/mysql-5.7-community/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

[mysql80-community]
name=MySQL 8.0 Community Server
baseurl=http://repo.mysql.com/yum/mysql-8.0-community/el/6/$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/el/6/$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/el/6/$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/el/6/$basearch/
enabled=0
gpgcheck=1
gpgkey=file:/etc/pki/rpm-gpg/RPM-GPG-KEY-mysql

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

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

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

Step 3: Verify MySQL Yum repository has been successfully added to your Linux system.

$ sudo yum repolist enabled | grep "mysql.*-community.*"
#Sample Output
[root@mysql8 centos]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community MySQL Connectors Community 121
mysql-tools-community MySQL Tools Community 87
mysql80-community MySQL 8.0 Community Server 141
[root@mysql8 centos]#

Step 4: Disable the sub-repository for the 5.7 series and enable the one for the 8.0 series:

$ sudo yum-config-manager --disable mysql57-community
$ sudo yum-config-manager --enable mysql80-community

If yum-config-manager command not found then install dependency

$ sudo yum install yum-utils -y

( Or )

Manually disable by editing the below file, search MySQL 5.7
/etc/yum.repos.d/mysql-community.repo

To disable specify enabled=0 for MySQL 5.7 and enabled=1 to MySQL 8
Disabling the Default MySQL Module – You need to disable default MySQL Module only in EL8 system eg: RHEL8, Oracle Linux 8 which includes mysql by default. $ sudo yum module disable mysql

Step 5: Install MySQL Server

$ sudo yum install mysql-community-server

========================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================
Installing:
mysql-community-libs x86_64 8.0.19-1.el6 mysql80-community 4.6 M
replacing mysql-libs.x86_64 5.1.73-7.el6
mysql-community-libs-compat x86_64 8.0.19-1.el6 mysql80-community 1.7 M
replacing mysql-libs.x86_64 5.1.73-7.el6
mysql-community-server x86_64 8.0.19-1.el6 mysql80-community 520 M
Installing for dependencies:
libaio x86_64 0.3.107-10.el6 base 21 k
mysql-community-client x86_64 8.0.19-1.el6 mysql80-community 47 M
mysql-community-common x86_64 8.0.19-1.el6 mysql80-community 727 k
numactl x86_64 2.0.9-2.el6 base 74 k
Updating for dependencies:
postfix x86_64 2:2.6.6-8.el6 base 2.0 M

Transaction Summary
========================================================================================================================================
Install 7 Package(s)
Upgrade 1 Package(s)

Total download size: 576 M
Is this ok [y/N]: y
Downloading Packages:..............
...
...

Step 6: Starting the MySQL Server and check the Mysqld service status

$ sudo service mysqld start

#Sample Output
[root@mysql8 yum.repos.d]# sudo service mysqld start
Initializing MySQL database: [ OK ]
Starting mysqld: [ OK ]
[root@mysql8 yum.repos.d]#

Now, check the status of the MySQL Server.
$ sudo service mysqld status

#Sample Output
[centos@mysql8 ~]$ sudo service mysqld status
mysqld (pid 10507) is running...
[centos@mysql8 ~]$

What all things happen at the initial startup of MySQL Server

  • The server is initialized.
  • SSL certificate and key files are generated in the data directory.
  • validate_password is installed and enabled.
  • A superuser account ‘root’@’localhost is created. A password for the superuser is set and stored in the error log file. To reveal it, use the following command:
    $ sudo grep 'temporary password' /var/log/mysqld.log

Change the MySQL Password

$ mysql -uroot -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'MyNewPass4MySQL!';
validate_password is installed by default. The default password policy implemented by validate_password requires that passwords contain at least one uppercase letter, one lowercase letter, one digit, and one special character and that the total password length is at least 8 characters.

Known Limitation
The 8.0.12 release requires you to adjust the libstdc++7 path by executing ln -s /opt/oracle/oracle-armtoolset-1/root/usr/lib64 /usr/lib64/gcc7 after executing the yum install step.

This is the end of tutorials, Steps to Install MySQL8 on CentOS or Amazon Linux.


Other Articles:

How to create YUM Repository from ISO or Online

What is Linux Software, yum and rpm

Linux System Admin Activities and Daily Job Responsibilities

Steps to connect Linux Server from windows using Putty

Steps to Install Docker on Ubuntu