[LINUX] Steps to install MySQL 8.0 on CentOS 8.1

I have installed ** MySQL 8.0 ** on ** CentOS 8.1 **, so I will explain the procedure. MySQL Official Page Was installed as a reference, so the manual is summarized and the actual execution results are posted.

environment

Installation procedure

1. Add MySQL Yum repository

Check the file name to install from the MySQL Yum Repository Download Page.

01.png

Here, since it is installed on ** CentOS 8.1 **, it will be mysql80-community-release-el8-1.noarch.rpm.

Connect to https://dev.mysql.com/get/ and install with the following command.

dnf localinstall https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm

Execution result


[root@centos8 ~]# dnf localinstall https://dev.mysql.com/get/mysql80-community-release-el8-1.noarch.rpm
CentOS-8 - AppStream                            5.3 kB/s | 4.3 kB     00:00
CentOS-8 - Base                                 5.7 kB/s | 3.8 kB     00:00
CentOS-8 - Extras                               2.2 kB/s | 1.5 kB     00:00
mysql80-community-release-el8-1.noarch.rpm       22 kB/s |  30 kB     00:01
The dependency has been resolved.
================================================================================
Package Arch version repository size
================================================================================
Installation:
 mysql80-community-release      noarch      el8-1       @commandline       30 k

Transaction overview
================================================================================
Installation 1 package

Total size: 30 k
Installed size: 29 k
Is this okay? [y/N]: y
Download package:
Performing transaction confirmation
The transaction was confirmed successfully.
Running transaction test
You have successfully tested the transaction.
Transaction is in progress
Preparation:                                                        1/1
During installation: mysql80-community-release-el8-1.noarch                 1/1
Verification: mysql80-community-release-el8-1.noarch                 1/1

Installation complete:
  mysql80-community-release-el8-1.noarch

Has completed!
[root@centos8 ~]#

Refer to /etc/yum.repos.d and confirm that the repository has been added.

Execution result


[root@centos8 ~]# cd /etc/yum.repos.d
[root@centos8 yum.repos.d]# ls -l
60 in total
-rw-r--r--.1 root root 731 March 13 04:15 CentOS-AppStream.repo
-rw-r--r--.1 root root 712 March 13 04:15 CentOS-Base.repo
-rw-r--r--.1 root root 1043 March 13 04:15 CentOS-CR.repo
-rw-r--r--.1 root root 668 March 13 04:15 CentOS-Debuginfo.repo
-rw-r--r--1 root root 743 March 13 04:15 CentOS-Devel.repo
-rw-r--r--.1 root root 756 March 13 04:15 CentOS-Extras.repo
-rw-r--r--.1 root root 738 March 13 04:15 CentOS-HA.repo
-rw-r--r--.1 root root 928 March 13 04:15 CentOS-Media.repo
-rw-r--r--.1 root root 736 March 13 04:15 CentOS-PowerTools.repo
-rw-r--r--.1 root root 1382 March 13 04:15 CentOS-Sources.repo
-rw-r--r--.1 root root 74 March 13 04:15 CentOS-Vault.repo
-rw-r--r--.1 root root 798 March 13 04:15 CentOS-centosplus.repo
-rw-r--r--.1 root root 338 March 13 04:15 CentOS-fasttrack.repo
-rw-r--r--1 root root 1050 October 4 2019 mysql-community-source.repo
-rw-r--r--1 root root 995 October 4 2019 mysql-community.repo
[root@centos8 yum.repos.d]#

Added mysql-community-source.repo and mysql-community.repo.

Make sure the MySQL repository is enabled with the following command.

dnf repolist enabled | grep "mysql.*-community.*"

[root@centos8 ~]# dnf repolist enabled | grep "mysql.*-community.*"
Final confirmation of metadata expiration: 0:11:It was held 26 hours ago on April 21, 2020 at 21:24:21.
mysql-connectors-community           MySQL Connectors Community               4
mysql-tools-community                MySQL Tools Community                    1
mysql80-community                    MySQL 8.0 Community Server               3
[root@centos8 ~]#

2. Disable the default MySQL module

Disable the default default MySQL module with the following command.

dnf module disable mysql

Execution result


[root@centos8 ~]# dnf module disable mysql
Final confirmation of metadata expiration: 0:15:It was held 51 hours ago on April 21, 2020 at 21:24:21.
The dependency has been resolved.
================================================================================
Package architecture version repository size
================================================================================
Disable module:
 mysql

Transaction overview
================================================================================

Is this okay? [y/N]: y
Has completed!
[root@centos8 ~]#

3. Install MySQL

Check the packages to be installed from the repository with the following command.

dnf info mysql-community-server

Execution result


[root@centos8 ~]# dnf info mysql-community-server
Final confirmation of metadata expiration: 0:21:It was held 54 hours ago on April 21, 2020 at 21:24:21.
Available packages
name: mysql-community-server
version: 8.0.19
release: 1.el8
Arch         : x86_64
size: 53 M
Source: mysql-community-8.0.19-1.el8.src.rpm
Repository: mysql80-community
Overview: A very fast and reliable SQL database server
URL          : http://www.mysql.com/
license: Copyright (c) 2000, 2019, Oracle and/or its affiliates. All
             : rights reserved. Under GPLv2 license as shown in the Description
             : field.
Description: The MySQL(TM) software delivers a very fast, multi-threaded,
             : multi-user, and robust SQL (Structured Query Language) database
             : server. MySQL Server is intended for mission-critical, heavy-load
             : production systems as well as for embedding into mass-deployed
             : software. MySQL is a trademark of Oracle and/or its affiliates
             :
             : The MySQL software has Dual Licensing, which means you can use
             : the MySQL software free of charge under the GNU General Public
             : License (http://www.gnu.org/licenses/). You can also purchase
             : commercial MySQL licenses from Oracle and/or its affiliates if
             : you do not wish to be bound by the terms of the GPL. See the
             : chapter "Licensing and Support" in the manual for further info.
             :
             : The MySQL web site (http://www.mysql.com/) provides the latest
             : news and information about the MySQL software.  Also please see
             : the documentation and the manual for more information.
             :
             : This package includes the MySQL server binary as well as related
             : utilities to run and administer a MySQL server.

[root@centos8 ~]#

Now that you have confirmed it, install it with the following command.

dnf install mysql-community-server

Execution result


[root@centos8 ~]# dnf install mysql-community-server
Final confirmation of metadata expiration: 0:23:It was held 16 hours ago on April 21, 2020 at 21:24:21.
The dependency has been resolved.
================================================================================
Package Arch version repository size
================================================================================
Installation:
 mysql-community-server    x86_64    8.0.19-1.el8    mysql80-community     53 M
Dependency installation:
 mysql-community-client    x86_64    8.0.19-1.el8    mysql80-community     12 M
 mysql-community-common    x86_64    8.0.19-1.el8    mysql80-community    609 k
 mysql-community-libs      x86_64    8.0.19-1.el8    mysql80-community    1.4 M

Transaction overview
================================================================================
Installation 4 packages

Total download size: 67 M
Installed size: 383 M
Is this okay? [y/N]: y
Download package:
(1/4): mysql-community-common-8.0.19-1.el8.x86_  90 kB/s | 609 kB     00:06
(2/4): mysql-community-libs-8.0.19-1.el8.x86_64  88 kB/s | 1.4 MB     00:16
(3/4): mysql-community-client-8.0.19-1.el8.x86_ 130 kB/s |  12 MB     01:35
(4/4): mysql-community-server-8.0.19-1.el8.x86_ 230 kB/s |  53 MB     03:56
--------------------------------------------------------------------------------
Total 284 kB/s |  67 MB     04:02
warning: /var/cache/dnf/mysql80-community-b1f1ed5ba88ce0f8/packages/mysql-community-client-8.0.19-1.el8.x86_64.rpm:Header V3 DSA/SHA1 Signature, key ID 5072e1f5: NOKEY
MySQL 8.0 Community Server                       27 MB/s |  27 kB     00:00
Importing GPG key 0x5072E1F5:
 Userid     : "MySQL Release Engineering <[email protected]>"
 Fingerprint: A4A9 4068 76FC BD3C 4567 70C8 8C71 8D3B 5072 E1F5
 From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-mysql
Is this okay? [y/N]: y
The key was successfully imported
Performing transaction confirmation
The transaction was confirmed successfully.
Running transaction test
You have successfully tested the transaction.
Transaction is in progress
Preparation:                                                        1/1
During installation: mysql-community-common-8.0.19-1.el8.x86_64             1/4
During installation: mysql-community-libs-8.0.19-1.el8.x86_64               2/4
scriptlet running: mysql-community-libs-8.0.19-1.el8.x86_64               2/4
During installation: mysql-community-client-8.0.19-1.el8.x86_64             3/4
scriptlet running: mysql-community-server-8.0.19-1.el8.x86_64             4/4
During installation: mysql-community-server-8.0.19-1.el8.x86_64             4/4
scriptlet running: mysql-community-server-8.0.19-1.el8.x86_64             4/4
Verification: mysql-community-client-8.0.19-1.el8.x86_64             1/4
Verification: mysql-community-common-8.0.19-1.el8.x86_64             2/4
Verification: mysql-community-libs-8.0.19-1.el8.x86_64               3/4
Verification: mysql-community-server-8.0.19-1.el8.x86_64             4/4

Installation complete:
  mysql-community-server-8.0.19-1.el8.x86_64
  mysql-community-client-8.0.19-1.el8.x86_64
  mysql-community-common-8.0.19-1.el8.x86_64
  mysql-community-libs-8.0.19-1.el8.x86_64

Has completed!
[root@centos8 ~]#

Make sure ** MySQL ** is installed with the following command.

mysqld --version

Execution result


[root@centos8 ~]# mysqld --version
/usr/sbin/mysqld  Ver 8.0.19 for Linux on x86_64 (MySQL Community Server - GPL)
[root@centos8 ~]#

4. Start MySQL

Start MySQL with the following command.

systemctl start mysqld

:console:Execution result


[root@centos8 ~]# systemctl start mysqld
[root@centos8 ~]#

5. Check connection

Find the initial password in the mysqld.log file.

grep 'temporary password' /var/log/mysqld.log

Execution result


[root@centos8 ~]# grep 'temporary password' /var/log/mysqld.log
2020-04-21T13:18:30.707097Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: T9sqNDtMTr.O
[root@centos8 ~]#

The initial password for root @ localhost is T9sqNDtMTr.O.

Connect to MySQL with the following command.

mysql -uroot -p [password]

Execution result


[root@centos8 ~]# mysql -uroot -pT9sqNDtMTr.O
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 9
Server version: 8.0.19

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>

6. Run mysql_secure_installation

You can run the following as a security factory by running mysql_secure_installation.

Execution result


[root@centos8 ~]# mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root:
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:

Re-enter new 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
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : y
 - Dropping test database...
Success.

 - 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@centos8 ~]#

Check the connection with the password changed with the following command.

mysql -uroot -p [password changed]

Execution result


[root@centos8 ~]# mysql -uroot -pPassword01!
mysql: [Warning] Using a password on the command line interface can be insecure.
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 15
Server version: 8.0.19 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> show databases;
+--------------------+
| Database           |
+--------------------+
| information_schema |
| mysql              |
| performance_schema |
| sys                |
+--------------------+
4 rows in set (0.01 sec)

mysql> exit
Bye
[root@centos8 ~]#

7. Authentication method setting

Starting with MySQL 8.0, the default authentication method has been changed to ** caching_sha2_password ** instead of ** mysql_native_password **. When using ** mysql_native_password ** as the authentication method, in the [mysqld] of the configuration file /etc/my.cnf # default-authentication-plugin=mysql_native_password Uncomment.

/etc/my.cnf


# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/8.0/en/server-configuration-defaults.html

[mysqld]
#
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
#
# Remove the leading "# " to disable binary logging
# Binary logging captures changes between backups and is enabled by
# default. It's default setting is log_bin=binlog
# disable_log_bin
#
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
#
# Remove leading # to revert to previous value for default_authentication_plugin,
# this will increase compatibility with older clients. For background, see:
# https://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_default_authentication_plugin
default-authentication-plugin=mysql_native_password

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid

reference

Official page "2.5.1 Installing MySQL on Linux Using the MySQL Yum Repository"

Official page "2.5.4 Installing MySQL on Linux Using RPM Packages from Oracle"

[Official page "4.4.2 mysql_secure_installation — Improve MySQL Installation Security"](https://dev.mysql.com/doc/refman/8.0/en/mysql-secure-installation.html "MySQL :: MySQL 8.0 Reference Manual" :: 4.4.2 mysql_secure_installation — Improve MySQL Installation Security ")


that's all

Recommended Posts

Steps to install MySQL 8.0 on CentOS 8.1
Steps to install VirtualBox on CentOS
Steps to deploy EMLauncher on CentOS 8
Steps to install matplotlib on Mac
How to install PyPy on CentOS
How to install TensorFlow on CentOS 7
How to install Maven on CentOS
Steps to install python3 on mac
Steps to install Python environment on Ubuntu
Connecting from python to MySQL on CentOS 6.4
How to install Apache (httpd) on CentOS7
How to install Eclipse GlassFish 5.1.0 on CentOS 7
How to install Apache (httpd) on CentOS8
Steps to install CentOS 8.1 in Virtual Box
Install numba on CentOS 7.2
Install Python3.4 on CentOS 6.6
Install mecab-python on CentOS
Install Python 2.7.3 on CentOS 5.4
Install awscli on centos7
Install Chainer on CentOS 6.7
Install ImageMagick-6.2.x series on CentOS7.7
Install Python 3.8 on CentOS 7 (SCL)
Install Chrome on CentOS 7 series
Install Python 3.8 on CentOS 8 (AppStream)
Steps to install the latest Python on your Mac
How to install Git GUI and Gitk on CentOS
How to install Python2.7 python3.5 with pyenv (on RHEL5 CentOS5) (2016 Nov)
raspberry pi 4 centos7 install on docker
How to install mysql-connector-python on mac
Steps to install Ubuntu in VirtualBox
How to install graph-tool on macOS
How to install VMware-Tools on Linux
How to install pycrypto on Windows
Install java (Oracle JDK14) on CentOS7
How to install OpenCV on Mac
Install pip on CentOS7. Also iPython.
Install VirtualBox on CentOS 7 on VirtualBox (mac + vagrant)
Install Python on CentOS using Pyenv
Study Note 9_Install Jenkins on CentOS7
How to install Go on Ubuntu
Install Python on CentOS using pyenv
How to install music 21 on windows
How to install aws-session-manager-plugin on Manajro Linux
How to install drobertadams / toggl-cli on Mac
Enable sar command on CentOS (install sysstat)
[Kivy] How to install Kivy on Windows [Python]
Upgraded mysql on Cloud9 (Amazon Linux) (5.5 to 5,7)
How to install packages on Alpine Linux
5 reasons to install Linux on your laptop.
How to install Anisble on Amazon Linux 2
How to switch mouse operations on CentOS
How to install richzhang / colorization on Windows 10
Install Mecab on Linux (CentOS) with brew
How to update security on CentOS Linux 8
Install python on xserver to use pip
How to install php7.4 on Linux (Ubuntu)
Personal Note Package to install on Anaconda
How to install NumPy on Raspberry Pi
Install PostgreSQL from source code on CentOS
How to install cx_Oracle on macOS Sierra
Install pyenv and rbenv on CentOS system-wide