How to Install MySQL 8.0 on Linux RHEL: In this article we will discuss about How to Install MySQL 8.0 on Linux RHEL step by step.
Steps to install MySQL server:
Step-1 Download and add MySQL Yum Repository to Linux Repository.
On RHEL/CentOS 8 ---------------
# wget https://repo.mysql.com/mysql80-community-release-el8-1.noarch.rpm
On RHEL/CentOS 7 ---------------
# wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
On RHEL/CentOS 6 ---------------
# wget https://dev.mysql.com/get/mysql80-community-release-el6-1.noarch.rpm
In my case i am using RHEL 7. So i use below command :
[root@vm-4 ~]#
[root@vm-4 ~]# wget https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
--2021-01-02 19:34:57-- https://repo.mysql.com/mysql80-community-release-el7-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 104.73.164.232
Connecting to repo.mysql.com (repo.mysql.com)|104.73.164.232|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 25820 (25K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el7-1.noarch.rpm’
100%[==============================================================================================================================>] 25,820 --.-K/s in 0.001s
2021-01-02 19:34:57 (48.3 MB/s) - ‘mysql80-community-release-el7-1.noarch.rpm’ saved [25820/25820]
[root@vm-4 ~]#
Step-2 Install the downloaded package by using below command.
On RHEL/CentOS 8 ---------------
# yum localinstall mysql80-community-release-el8-1.noarch.rpm
On RHEL/CentOS 7 ---------------
# yum localinstall mysql80-community-release-el7-1.noarch.rpm
On RHEL/CentOS 6 ---------------
# yum localinstall mysql80-community-release-el6-1.noarch.rpm
In my case i am using RHEL 7. So i use below command :
[root@vm-4 ~]#
[root@vm-4 ~]# yum localinstall mysql80-community-release-el7-1.noarch.rpm
Loaded plugins: langpacks, ulninfo
Examining mysql80-community-release-el7-1.noarch.rpm: mysql80-community-release-el7-1.noarch
Marking mysql80-community-release-el7-1.noarch.rpm to be installed
Resolving Dependencies
--> Running transaction check
---> Package mysql80-community-release.noarch 0:el7-1 will be installed
--> Finished Dependency Resolution
ol7_UEKR5/x86_64 | 2.5 kB 00:00:00
ol7_latest/x86_64 | 2.7 kB 00:00:00
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
mysql80-community-release noarch el7-1 /mysql80-community-release-el7-1.noarch 31 k
Transaction Summary
========================================================================================================================================================================
Install 1 Package
Total size: 31 k
Installed size: 31 k
Is this ok [y/d/N]: y
Downloading packages:
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Installing : mysql80-community-release-el7-1.noarch 1/1
Verifying : mysql80-community-release-el7-1.noarch 1/1
Installed:
mysql80-community-release.noarch 0:el7-1
Complete!
[root@vm-4 ~]#
Step-3 Verify that the MySQL Yum repository has been added successfully
[root@vm-4 ~]#
[root@vm-4 ~]# yum repolist enabled | grep "mysql.*-community.*"
mysql-connectors-community/x86_64 MySQL Connectors Community 175
mysql-tools-community/x86_64 MySQL Tools Community 120
mysql80-community/x86_64 MySQL 8.0 Community Server 211
[root@vm-4 ~]#
Step-4 Install latest MySQL that is going to be MySQL 8.0 :
[root@vm-4 ~]#
[root@vm-4 ~]# yum install mysql-community-server
Loaded plugins: langpacks, ulninfo
Resolving Dependencies
--> Running transaction check
---> Package mariadb.x86_64 1:5.5.65-1.el7 will be obsoleted
--> Processing Dependency: mariadb(x86-64) = 1:5.5.65-1.el7 for package: 1:mariadb-server-5.5.65-1.el7.x86_64
---> Package mysql-community-client.x86_64 0:8.0.22-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-client-plugins = 8.0.22-1.el7 for package: mysql-community-client-8.0.22-1.el7.x86_64
--> Processing Dependency: mysql-community-libs(x86-64) >= 8.0.11 for package: mysql-community-client-8.0.22-1.el7.x86_64
--> Running transaction check
---> Package mariadb-libs.x86_64 1:5.5.65-1.el7 will be obsoleted
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:net-snmp-5.7.2-47.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: perl-DBD-MySQL-4.023-6.0.1.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:net-snmp-agent-libs-5.7.2-47.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18()(64bit) for package: 1:qt-mysql-4.8.7-8.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: perl-DBD-MySQL-4.023-6.0.1.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 2:postfix-2.10.1-9.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 1:net-snmp-agent-libs-5.7.2-47.el7.x86_64
--> Processing Dependency: libmysqlclient.so.18(libmysqlclient_18)(64bit) for package: 1:qt-mysql-4.8.7-8.el7.x86_64
---> Package mariadb-server.x86_64 1:5.5.65-1.el7 will be obsoleted
---> Package mysql-community-client-plugins.x86_64 0:8.0.22-1.el7 will be installed
---> Package mysql-community-libs.x86_64 0:8.0.22-1.el7 will be obsoleting
--> Processing Dependency: mysql-community-common(x86-64) >= 8.0.11 for package: mysql-community-libs-8.0.22-1.el7.x86_64
---> Package mysql-community-server.x86_64 0:8.0.22-1.el7 will be obsoleting
--> Running transaction check
---> Package mysql-community-common.x86_64 0:8.0.22-1.el7 will be installed
---> Package mysql-community-libs-compat.x86_64 0:8.0.22-1.el7 will be obsoleting
---> Package net-snmp.x86_64 1:5.7.2-47.el7 will be updated
---> Package net-snmp.x86_64 1:5.7.2-49.el7_9.1 will be an update
--> Processing Dependency: net-snmp-libs = 1:5.7.2-49.el7_9.1 for package: 1:net-snmp-5.7.2-49.el7_9.1.x86_64
---> Package net-snmp-agent-libs.x86_64 1:5.7.2-47.el7 will be updated
---> Package net-snmp-agent-libs.x86_64 1:5.7.2-49.el7_9.1 will be an update
---> Package qt-mysql.x86_64 1:4.8.7-8.el7 will be updated
---> Package qt-mysql.x86_64 1:4.8.7-9.el7_9 will be an update
--> Processing Dependency: qt(x86-64) = 1:4.8.7-9.el7_9 for package: 1:qt-mysql-4.8.7-9.el7_9.x86_64
--> Running transaction check
---> Package net-snmp-libs.x86_64 1:5.7.2-47.el7 will be updated
--> Processing Dependency: net-snmp-libs = 1:5.7.2-47.el7 for package: 1:net-snmp-utils-5.7.2-47.el7.x86_64
---> Package net-snmp-libs.x86_64 1:5.7.2-49.el7_9.1 will be an update
---> Package qt.x86_64 1:4.8.7-8.el7 will be updated
--> Processing Dependency: qt(x86-64) = 1:4.8.7-8.el7 for package: 1:qt-x11-4.8.7-8.el7.x86_64
---> Package qt.x86_64 1:4.8.7-9.el7_9 will be an update
--> Running transaction check
---> Package net-snmp-utils.x86_64 1:5.7.2-47.el7 will be updated
---> Package net-snmp-utils.x86_64 1:5.7.2-49.el7_9.1 will be an update
---> Package qt-x11.x86_64 1:4.8.7-8.el7 will be updated
---> Package qt-x11.x86_64 1:4.8.7-9.el7_9 will be an update
--> Finished Dependency Resolution
Dependencies Resolved
========================================================================================================================================================================
Package Arch Version Repository Size
========================================================================================================================================================================
Installing:
mysql-community-client x86_64 8.0.22-1.el7 mysql80-community 48 M
replacing mariadb.x86_64 1:5.5.65-1.el7
mysql-community-libs x86_64 8.0.22-1.el7 mysql80-community 4.6 M
replacing mariadb-libs.x86_64 1:5.5.65-1.el7
mysql-community-libs-compat x86_64 8.0.22-1.el7 mysql80-community 1.2 M
replacing mariadb-libs.x86_64 1:5.5.65-1.el7
mysql-community-server x86_64 8.0.22-1.el7 mysql80-community 510 M
replacing mariadb-server.x86_64 1:5.5.65-1.el7
Installing for dependencies:
mysql-community-client-plugins x86_64 8.0.22-1.el7 mysql80-community 235 k
mysql-community-common x86_64 8.0.22-1.el7 mysql80-community 616 k
Updating for dependencies:
net-snmp x86_64 1:5.7.2-49.el7_9.1 ol7_latest 324 k
net-snmp-agent-libs x86_64 1:5.7.2-49.el7_9.1 ol7_latest 706 k
net-snmp-libs x86_64 1:5.7.2-49.el7_9.1 ol7_latest 751 k
net-snmp-utils x86_64 1:5.7.2-49.el7_9.1 ol7_latest 200 k
qt x86_64 1:4.8.7-9.el7_9 ol7_latest 4.6 M
qt-mysql x86_64 1:4.8.7-9.el7_9 ol7_latest 31 k
qt-x11 x86_64 1:4.8.7-9.el7_9 ol7_latest 13 M
Transaction Summary
========================================================================================================================================================================
Install 4 Packages (+2 Dependent packages)
Upgrade ( 7 Dependent packages)
Total size: 583 M
Total download size: 564 M
Is this ok [y/d/N]: y
Downloading packages:
warning: /var/cache/yum/x86_64/7Server/mysql80-community/packages/mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm: Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
Public key for mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm is not installed
(1/6): mysql-community-client-plugins-8.0.22-1.el7.x86_64.rpm | 235 kB 00:00:00
(2/6): mysql-community-common-8.0.22-1.el7.x86_64.rpm | 616 kB 00:00:00
(3/6): mysql-community-libs-8.0.22-1.el7.x86_64.rpm | 4.6 MB 00:00:01
(4/6): mysql-community-libs-compat-8.0.22-1.el7.x86_64.rpm | 1.2 MB 00:00:00
(5/6): mysql-community-client-8.0.22-1.el7.x86_64.rpm | 48 MB 00:00:16
(6/6): mysql-community-server-8.0.22-1.el7.x86_64.rpm | 510 MB 00:01:38
------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total 5.5 MB/s | 564 MB 00:01:42
Retrieving key from file:///etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Importing GPG key 0x5072E1F5:
Userid : "MySQL Release Engineering <mysql-build@oss.oracle.com>"
Fingerprint: a4a9 4068 76fc bd3c 4567 70c8 8c71 8d3b 5072 e1f5
Package : mysql80-community-release-el7-1.noarch (@/mysql80-community-release-el7-1.noarch)
From : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this ok [y/N]: y
Running transaction check
Running transaction test
Transaction test succeeded
Running transaction
Updating : 1:net-snmp-libs-5.7.2-49.el7_9.1.x86_64 1/23
Installing : mysql-community-client-plugins-8.0.22-1.el7.x86_64 2/23
Updating : 1:qt-4.8.7-9.el7_9.x86_64 3/23
Installing : mysql-community-common-8.0.22-1.el7.x86_64 4/23
Installing : mysql-community-libs-8.0.22-1.el7.x86_64 5/23
Installing : mysql-community-libs-compat-8.0.22-1.el7.x86_64 6/23
Updating : 1:net-snmp-agent-libs-5.7.2-49.el7_9.1.x86_64 7/23
Installing : mysql-community-client-8.0.22-1.el7.x86_64 8/23
Installing : mysql-community-server-8.0.22-1.el7.x86_64 9/23
Updating : 1:net-snmp-5.7.2-49.el7_9.1.x86_64 10/23
Updating : 1:qt-mysql-4.8.7-9.el7_9.x86_64 11/23
Updating : 1:qt-x11-4.8.7-9.el7_9.x86_64 12/23
Updating : 1:net-snmp-utils-5.7.2-49.el7_9.1.x86_64 13/23
Cleanup : 1:net-snmp-5.7.2-47.el7.x86_64 14/23
Cleanup : 1:qt-mysql-4.8.7-8.el7.x86_64 15/23
Cleanup : 1:net-snmp-agent-libs-5.7.2-47.el7.x86_64 16/23
Erasing : 1:mariadb-server-5.5.65-1.el7.x86_64 17/23
Erasing : 1:mariadb-5.5.65-1.el7.x86_64 18/23
Cleanup : 1:qt-x11-4.8.7-8.el7.x86_64 19/23
Cleanup : 1:net-snmp-utils-5.7.2-47.el7.x86_64 20/23
Cleanup : 1:net-snmp-libs-5.7.2-47.el7.x86_64 21/23
Cleanup : 1:qt-4.8.7-8.el7.x86_64 22/23
Erasing : 1:mariadb-libs-5.5.65-1.el7.x86_64 23/23
Verifying : 1:net-snmp-utils-5.7.2-49.el7_9.1.x86_64 1/23
Verifying : mysql-community-common-8.0.22-1.el7.x86_64 2/23
Verifying : mysql-community-server-8.0.22-1.el7.x86_64 3/23
Verifying : mysql-community-client-8.0.22-1.el7.x86_64 4/23
Verifying : 1:qt-4.8.7-9.el7_9.x86_64 5/23
Verifying : mysql-community-libs-compat-8.0.22-1.el7.x86_64 6/23
Verifying : mysql-community-client-plugins-8.0.22-1.el7.x86_64 7/23
Verifying : 1:qt-x11-4.8.7-9.el7_9.x86_64 8/23
Verifying : 1:qt-mysql-4.8.7-9.el7_9.x86_64 9/23
Verifying : 1:net-snmp-5.7.2-49.el7_9.1.x86_64 10/23
Verifying : mysql-community-libs-8.0.22-1.el7.x86_64 11/23
Verifying : 1:net-snmp-agent-libs-5.7.2-49.el7_9.1.x86_64 12/23
Verifying : 1:net-snmp-libs-5.7.2-49.el7_9.1.x86_64 13/23
Verifying : 1:mariadb-server-5.5.65-1.el7.x86_64 14/23
Verifying : 1:net-snmp-5.7.2-47.el7.x86_64 15/23
Verifying : 1:qt-mysql-4.8.7-8.el7.x86_64 16/23
Verifying : 1:mariadb-5.5.65-1.el7.x86_64 17/23
Verifying : 1:qt-x11-4.8.7-8.el7.x86_64 18/23
Verifying : 1:net-snmp-agent-libs-5.7.2-47.el7.x86_64 19/23
Verifying : 1:net-snmp-libs-5.7.2-47.el7.x86_64 20/23
Verifying : 1:mariadb-libs-5.5.65-1.el7.x86_64 21/23
Verifying : 1:net-snmp-utils-5.7.2-47.el7.x86_64 22/23
Verifying : 1:qt-4.8.7-8.el7.x86_64 23/23
Installed:
mysql-community-client.x86_64 0:8.0.22-1.el7 mysql-community-libs.x86_64 0:8.0.22-1.el7 mysql-community-libs-compat.x86_64 0:8.0.22-1.el7
mysql-community-server.x86_64 0:8.0.22-1.el7
Dependency Installed:
mysql-community-client-plugins.x86_64 0:8.0.22-1.el7 mysql-community-common.x86_64 0:8.0.22-1.el7
Dependency Updated:
net-snmp.x86_64 1:5.7.2-49.el7_9.1 net-snmp-agent-libs.x86_64 1:5.7.2-49.el7_9.1 net-snmp-libs.x86_64 1:5.7.2-49.el7_9.1 net-snmp-utils.x86_64 1:5.7.2-49.el7_9.1
qt.x86_64 1:4.8.7-9.el7_9 qt-mysql.x86_64 1:4.8.7-9.el7_9 qt-x11.x86_64 1:4.8.7-9.el7_9
Replaced:
mariadb.x86_64 1:5.5.65-1.el7 mariadb-libs.x86_64 1:5.5.65-1.el7 mariadb-server.x86_64 1:5.5.65-1.el7
Complete!
[root@vm-4 ~]#
Step-5 Check mysql version by using below command :
[root@vm-4 ~]#
[root@vm-4 ~]# mysql --version
mysql Ver 8.0.22 for Linux on x86_64 (MySQL Community Server - GPL)
[root@vm-4 ~]#
Step-6 Start MySQL Server :
[root@vm-4 ~]#
[root@vm-4 ~]# sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: inactive (dead)
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
[root@vm-4 ~]#
[root@vm-4 ~]# sudo service mysqld start
Redirecting to /bin/systemctl start mysqld.service
[root@vm-4 ~]#
[root@vm-4 ~]# sudo service mysqld status
Redirecting to /bin/systemctl status mysqld.service
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2021-01-02 20:06:25 IST; 14s ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 24925 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 25047 (mysqld)
Status: "Server is operational"
Tasks: 38
CGroup: /system.slice/mysqld.service
└─25047 /usr/sbin/mysqld
Jan 02 20:05:50 vm-4.localdomain systemd[1]: Starting MySQL Server...
Jan 02 20:06:25 vm-4.localdomain systemd[1]: Started MySQL Server.
[root@vm-4 ~]#
Step-7 Securing the MySQL Installation :
When MySQL 8.0 version is installed, temporary password for root is created in /var/log/mysqld.log. To view this temporary password run below command.
[root@vm-4 ~]#
[root@vm-4 ~]# grep 'temporary password' /var/log/mysqld.log
2021-01-02T14:36:09.660607Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: tMWxiNo*/6M2
[root@vm-4 ~]#
After getting the temporary password you need to run this below command. It will prompt you to provide the password. Provide the temporary password which you get from /var/log/mysqld.log and then change the root password.
[root@vm-4 ~]#
[root@vm-4 ~]# sudo mysql_secure_installation
Securing the MySQL server deployment.
Enter password for user root: Enter Temporary Root Password
The existing password for the user account root has expired. Please set a new password.
New password: Enter New Root Password
Re-enter new password:
The 'validate_password' component is installed on the server.
The subsequent steps will run with the existing configuration
of the component.
Using existing password for root.
Estimated strength of the password: 100
Change the password for root ? ((Press y|Y for Yes, any other key for No) : y
New password: Set New MySQL Password
Re-enter new password: Re-enter New MySQL Password
Estimated strength of the password: 100
Do you wish to continue with the password provided?(Press y|Y for Yes, any other key for No) : y
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.
Remove anonymous users? (Press y|Y for Yes, any other key for No) : y
Success.
Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.
Disallow root login remotely? (Press y|Y for Yes, any other key for No) : y
- Dropping test database...
Success.
Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
- Removing privileges on test database...
Success.
Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.
Reload privilege tables now? (Press y|Y for Yes, any other key for No) : y
Success.
All done!
[root@vm-4 ~]#
Step-8 Check MySQL server status :
Your installation of MySQL 8.0 Server is completed. To check MySQL Server is running or not, run below command.
[root@vm-4 ~]#
[root@vm-4 ~]# sudo systemctl status mysqld
● mysqld.service - MySQL Server
Loaded: loaded (/usr/lib/systemd/system/mysqld.service; enabled; vendor preset: disabled)
Active: active (running) since Sat 2021-01-02 20:06:25 IST; 18min ago
Docs: man:mysqld(8)
http://dev.mysql.com/doc/refman/en/using-systemd.html
Process: 24925 ExecStartPre=/usr/bin/mysqld_pre_systemd (code=exited, status=0/SUCCESS)
Main PID: 25047 (mysqld)
Status: "Server is operational"
Tasks: 38
CGroup: /system.slice/mysqld.service
└─25047 /usr/sbin/mysqld
Jan 02 20:05:50 vm-4.localdomain systemd[1]: Starting MySQL Server...
Jan 02 20:06:25 vm-4.localdomain systemd[1]: Started MySQL Server.
[root@vm-4 ~]#
Step-9 To Connecting to MySQL Server, you can use below command.
Run below command to connect mysql server it will prompt you to provide the root password.
[root@vm-4 ~]#
[root@vm-4 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 11
Server version: 8.0.22 MySQL Community Server - GPL
Copyright (c) 2000, 2020, Oracle and/or its affiliates. All rights reserved.
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>
mysql>
I hope my written content will helped you. Your suggestions/feedback are most welcome from orakldba.com.
Keep learning… Have a great day!!!
Please comment here for your any query related to above content. You could write to mail me through : orakldba@gmail.com.