CentOS 8下安装MySql 8

1.设备

规格:华为云弹性服务器 2vCPUs | 4GiB | s3.large.2

镜像:CentOS 8.2 64bit

2.获取下载地址

地址:https://dev.mysql.com/downloads/

版本选择:mysql80-community-release-el9-1.noarch.rpm

获取下载地址:https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm

3.下载

[root@ecs-218624 ~]# wget https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
--2023-01-29 19:53:51--  https://repo.mysql.com//mysql80-community-release-el9-1.noarch.rpm
Resolving repo.mysql.com (repo.mysql.com)... 23.12.44.219
Connecting to repo.mysql.com (repo.mysql.com)|23.12.44.219|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 10534 (10K) [application/x-redhat-package-manager]
Saving to: ‘mysql80-community-release-el9-1.noarch.rpm’

mysql80-community-release-el9-1.noarch.rpm      100%[======================================================================================================>]  10.29K  --.-KB/s    in 0s

2023-01-29 19:53:52 (233 MB/s) - ‘mysql80-community-release-el9-1.noarch.rpm’ saved [10534/10534]

4.安装repo

[root@ecs-218624 ~]# rpm -i mysql80-community-release-el9-1.noarch.rpm
warning: mysql80-community-release-el9-1.noarch.rpm: Header V4 RSA/SHA256 Signature, key ID 3a79bd29: NOKEY

5.安装mysql-server


[root@ecs-218624 ~]# yum install mysql-server
CentOS-8 - AppStream                                                                                                                                           2.5 MB/s | 8.4 MB     00:03
CentOS-8 - Base                                                                                                                                                 24 MB/s | 4.6 MB     00:00
CentOS-8 - Extras                                                                                                                                               21 kB/s |  10 kB     00:00
Extra Packages for Enterprise Linux 8 - x86_64                                                                                                                  97 kB/s |  13 MB     02:20
Extra Packages for Enterprise Linux Modular 8 - x86_64                                                                                                          68 kB/s | 733 kB     00:10
MySQL 8.0 Community Server                                                                                                                                     147 kB/s | 628 kB     00:04
MySQL Connectors Community                                                                                                                                     5.3 kB/s |  14 kB     00:02
MySQL Tools Community                                                                                                                                           90 kB/s | 204 kB     00:02
Last metadata expiration check: 0:00:01 ago on Sun 29 Jan 2023 08:05:52 PM CST.
Dependencies resolved.
===============================================================================================================================================================================================
 Package                                              Architecture                   Version                                                           Repository                         Size
===============================================================================================================================================================================================
Installing:
 mysql-server                                         x86_64                         8.0.26-1.module_el8.4.0+915+de215114                              AppStream                          25 M
Installing dependencies:
 checkpolicy                                          x86_64                         2.9-1.el8                                                         BaseOS                            348 k
 libaio                                               x86_64                         0.3.112-1.el8                                                     BaseOS                             33 k
 mariadb-connector-c-config                           noarch                         3.1.11-2.el8_3                                                    AppStream                          15 k
 mecab                                                x86_64                         0.996-1.module_el8.4.0+589+11e12751.9                             AppStream                         393 k
 mysql                                                x86_64                         8.0.26-1.module_el8.4.0+915+de215114                              AppStream                          12 M
 mysql-common                                         x86_64                         8.0.26-1.module_el8.4.0+915+de215114                              AppStream                         134 k
 mysql-errmsg                                         x86_64                         8.0.26-1.module_el8.4.0+915+de215114                              AppStream                         598 k
 perl-Carp                                            noarch                         1.42-396.el8                                                      BaseOS                             30 k
 perl-Data-Dumper                                     x86_64                         2.167-399.el8                                                     BaseOS                             58 k
 perl-Digest                                          noarch                         1.17-395.el8                                                      AppStream                          27 k
 perl-Digest-MD5                                      x86_64                         2.55-396.el8                                                      AppStream                          37 k
 perl-Encode                                          x86_64                         4:2.97-3.el8                                                      BaseOS                            1.5 M
 perl-Errno                                           x86_64                         1.28-420.el8                                                      BaseOS                             76 k
 perl-Exporter                                        noarch                         5.72-396.el8                                                      BaseOS                             34 k
 perl-File-Path                                       noarch                         2.15-2.el8                                                        BaseOS                             38 k
 perl-File-Temp                                       noarch                         0.230.600-1.el8                                                   BaseOS                             63 k
 perl-Getopt-Long                                     noarch                         1:2.50-4.el8                                                      BaseOS                             63 k
 perl-HTTP-Tiny                                       noarch                         0.074-1.el8                                                       BaseOS                             58 k
 perl-IO                                              x86_64                         1.38-420.el8                                                      BaseOS                            142 k
 perl-MIME-Base64                                     x86_64                         3.15-396.el8                                                      BaseOS                             31 k
 perl-Net-SSLeay                                      x86_64                         1.88-1.module_el8.3.0+410+ff426aa3                                AppStream                         379 k
 perl-PathTools                                       x86_64                         3.74-1.el8                                                        BaseOS                             90 k
 perl-Pod-Escapes                                     noarch                         1:1.07-395.el8                                                    BaseOS                             20 k
 perl-Pod-Perldoc                                     noarch                         3.28-396.el8                                                      BaseOS                             86 k
 perl-Pod-Simple                                      noarch                         1:3.35-395.el8                                                    BaseOS                            213 k
 perl-Pod-Usage                                       noarch                         4:1.69-395.el8                                                    BaseOS                             34 k
 perl-Scalar-List-Utils                               x86_64                         3:1.49-2.el8                                                      BaseOS                             68 k
 perl-Socket                                          x86_64                         4:2.027-3.el8                                                     BaseOS                             59 k
 perl-Storable                                        x86_64                         1:3.11-3.el8                                                      BaseOS                             98 k
 perl-Term-ANSIColor                                  noarch                         4.06-396.el8                                                      BaseOS                             46 k
 perl-Term-Cap                                        noarch                         1.17-395.el8                                                      BaseOS                             23 k
 perl-Text-ParseWords                                 noarch                         3.30-395.el8                                                      BaseOS                             18 k
 perl-Text-Tabs+Wrap                                  noarch                         2013.0523-395.el8                                                 BaseOS                             24 k
 perl-Time-Local                                      noarch                         1:1.280-1.el8                                                     BaseOS                             34 k
 perl-URI                                             noarch                         1.73-3.el8                                                        AppStream                         116 k
 perl-Unicode-Normalize                               x86_64                         1.25-396.el8                                                      BaseOS                             82 k
 perl-constant                                        noarch                         1.33-396.el8                                                      BaseOS                             25 k
 perl-interpreter                                     x86_64                         4:5.26.3-420.el8                                                  BaseOS                            6.3 M
 perl-libnet                                          noarch                         3.11-3.el8                                                        AppStream                         121 k
 perl-libs                                            x86_64                         4:5.26.3-420.el8                                                  BaseOS                            1.6 M
 perl-macros                                          x86_64                         4:5.26.3-420.el8                                                  BaseOS                             72 k
 perl-parent                                          noarch                         1:0.237-1.el8                                                     BaseOS                             20 k
 perl-podlators                                       noarch                         4.11-1.el8                                                        BaseOS                            118 k
 perl-threads                                         x86_64                         1:2.21-2.el8                                                      BaseOS                             61 k
 perl-threads-shared                                  x86_64                         1.58-2.el8                                                        BaseOS                             48 k
 policycoreutils-python-utils                         noarch                         2.9-16.el8                                                        BaseOS                            252 k
 protobuf-lite                                        x86_64                         3.5.0-13.el8                                                      AppStream                         149 k
 python3-audit                                        x86_64                         3.0-0.17.20191104git1c2f876.el8                                   BaseOS                             86 k
 python3-libsemanage                                  x86_64                         2.9-6.el8                                                         BaseOS                            127 k
 python3-policycoreutils                              noarch                         2.9-16.el8                                                        BaseOS                            2.2 M
 python3-setools                                      x86_64                         4.3.0-2.el8                                                       BaseOS                            626 k
Installing weak dependencies:
 perl-IO-Socket-IP                                    noarch                         0.39-5.el8                                                        AppStream                          47 k
 perl-IO-Socket-SSL                                   noarch                         2.066-4.module_el8.3.0+410+ff426aa3                               AppStream                         298 k
 perl-Mozilla-CA                                      noarch                         20160104-7.module_el8.3.0+416+dee7bcef                            AppStream                          15 k
Enabling module streams:
 mysql                                                                               8.0
 perl                                                                                5.26
 perl-IO-Socket-SSL                                                                  2.066
 perl-libwww-perl                                                                    6.34

Transaction Summary
===============================================================================================================================================================================================
Install  55 Packages

Total download size: 54 M
Installed size: 241 M
Is this ok [y/N]: y
Downloading Packages:
(1/55): mariadb-connector-c-config-3.1.11-2.el8_3.noarch.rpm                                                                                                   269 kB/s |  15 kB     00:00
(2/55): mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64.rpm                                                                                                 4.4 MB/s | 393 kB     00:00
(3/55): mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64.rpm                                                                                           3.5 MB/s | 134 kB     00:00
(4/55): mysql-errmsg-8.0.26-1.module_el8.4.0+915+de215114.x86_64.rpm                                                                                           9.4 MB/s | 598 kB     00:00
(5/55): perl-Digest-1.17-395.el8.noarch.rpm                                                                                                                    1.9 MB/s |  27 kB     00:00
(6/55): perl-Digest-MD5-2.55-396.el8.x86_64.rpm                                                                                                                2.5 MB/s |  37 kB     00:00
(7/55): perl-IO-Socket-IP-0.39-5.el8.noarch.rpm                                                                                                                1.7 MB/s |  47 kB     00:00
(8/55): perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch.rpm                                                                                       13 MB/s | 298 kB     00:00
(9/55): perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch.rpm                                                                                      1.1 MB/s |  15 kB     00:00
(10/55): perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64.rpm                                                                                          13 MB/s | 379 kB     00:00
(11/55): perl-URI-1.73-3.el8.noarch.rpm                                                                                                                        6.1 MB/s | 116 kB     00:00
(12/55): perl-libnet-3.11-3.el8.noarch.rpm                                                                                                                     6.1 MB/s | 121 kB     00:00
(13/55): protobuf-lite-3.5.0-13.el8.x86_64.rpm                                                                                                                 4.2 MB/s | 149 kB     00:00
(14/55): checkpolicy-2.9-1.el8.x86_64.rpm                                                                                                                       13 MB/s | 348 kB     00:00
(15/55): libaio-0.3.112-1.el8.x86_64.rpm                                                                                                                       1.1 MB/s |  33 kB     00:00
(16/55): perl-Carp-1.42-396.el8.noarch.rpm                                                                                                                     403 kB/s |  30 kB     00:00
(17/55): perl-Data-Dumper-2.167-399.el8.x86_64.rpm                                                                                                             1.6 MB/s |  58 kB     00:00
(18/55): mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64.rpm                                                                                                  18 MB/s |  12 MB     00:00
(19/55): perl-Errno-1.28-420.el8.x86_64.rpm                                                                                                                    4.8 MB/s |  76 kB     00:00
(20/55): perl-Exporter-5.72-396.el8.noarch.rpm                                                                                                                 1.6 MB/s |  34 kB     00:00
(21/55): perl-File-Path-2.15-2.el8.noarch.rpm                                                                                                                  1.9 MB/s |  38 kB     00:00
(22/55): perl-File-Temp-0.230.600-1.el8.noarch.rpm                                                                                                             3.9 MB/s |  63 kB     00:00
(23/55): perl-Getopt-Long-2.50-4.el8.noarch.rpm                                                                                                                4.0 MB/s |  63 kB     00:00
(24/55): perl-HTTP-Tiny-0.074-1.el8.noarch.rpm                                                                                                                 3.7 MB/s |  58 kB     00:00
(25/55): perl-IO-1.38-420.el8.x86_64.rpm                                                                                                                       8.1 MB/s | 142 kB     00:00
(26/55): perl-MIME-Base64-3.15-396.el8.x86_64.rpm                                                                                                              1.9 MB/s |  31 kB     00:00
(27/55): mysql-server-8.0.26-1.module_el8.4.0+915+de215114.x86_64.rpm                                                                                           30 MB/s |  25 MB     00:00
(28/55): perl-PathTools-3.74-1.el8.x86_64.rpm                                                                                                                  712 kB/s |  90 kB     00:00
(29/55): perl-Pod-Escapes-1.07-395.el8.noarch.rpm                                                                                                              1.3 MB/s |  20 kB     00:00
(30/55): perl-Pod-Simple-3.35-395.el8.noarch.rpm                                                                                                                11 MB/s | 213 kB     00:00
(31/55): perl-Pod-Usage-1.69-395.el8.noarch.rpm                                                                                                                2.3 MB/s |  34 kB     00:00
(32/55): perl-Scalar-List-Utils-1.49-2.el8.x86_64.rpm                                                                                                          3.9 MB/s |  68 kB     00:00
(33/55): perl-Socket-2.027-3.el8.x86_64.rpm                                                                                                                    3.2 MB/s |  59 kB     00:00
(34/55): perl-Storable-3.11-3.el8.x86_64.rpm                                                                                                                   2.6 MB/s |  98 kB     00:00
(35/55): perl-Term-ANSIColor-4.06-396.el8.noarch.rpm                                                                                                           2.9 MB/s |  46 kB     00:00
(36/55): perl-Term-Cap-1.17-395.el8.noarch.rpm                                                                                                                 1.5 MB/s |  23 kB     00:00
(37/55): perl-Text-ParseWords-3.30-395.el8.noarch.rpm                                                                                                          1.0 MB/s |  18 kB     00:00
(38/55): perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch.rpm                                                                                                      1.7 MB/s |  24 kB     00:00
(39/55): perl-Time-Local-1.280-1.el8.noarch.rpm                                                                                                                2.3 MB/s |  34 kB     00:00
(40/55): perl-Unicode-Normalize-1.25-396.el8.x86_64.rpm                                                                                                        4.6 MB/s |  82 kB     00:00
(41/55): perl-constant-1.33-396.el8.noarch.rpm                                                                                                                 1.6 MB/s |  25 kB     00:00
(42/55): perl-interpreter-5.26.3-420.el8.x86_64.rpm                                                                                                             44 MB/s | 6.3 MB     00:00
(43/55): perl-Encode-2.97-3.el8.x86_64.rpm                                                                                                                     684 kB/s | 1.5 MB     00:02
(44/55): perl-macros-5.26.3-420.el8.x86_64.rpm                                                                                                                 258 kB/s |  72 kB     00:00
(45/55): perl-parent-0.237-1.el8.noarch.rpm                                                                                                                    823 kB/s |  20 kB     00:00
(46/55): perl-podlators-4.11-1.el8.noarch.rpm                                                                                                                  1.4 MB/s | 118 kB     00:00
(47/55): perl-threads-2.21-2.el8.x86_64.rpm                                                                                                                    206 kB/s |  61 kB     00:00
(48/55): perl-threads-shared-1.58-2.el8.x86_64.rpm                                                                                                             1.4 MB/s |  48 kB     00:00
(49/55): policycoreutils-python-utils-2.9-16.el8.noarch.rpm                                                                                                    1.6 MB/s | 252 kB     00:00
(50/55): python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64.rpm                                                                                              1.0 MB/s |  86 kB     00:00
(51/55): python3-libsemanage-2.9-6.el8.x86_64.rpm                                                                                                              1.6 MB/s | 127 kB     00:00
(52/55): python3-policycoreutils-2.9-16.el8.noarch.rpm                                                                                                         1.3 MB/s | 2.2 MB     00:01
(53/55): python3-setools-4.3.0-2.el8.x86_64.rpm                                                                                                                954 kB/s | 626 kB     00:00
(54/55): perl-libs-5.26.3-420.el8.x86_64.rpm                                                                                                                   249 kB/s | 1.6 MB     00:06
(55/55): perl-Pod-Perldoc-3.28-396.el8.noarch.rpm                                                                                                               11 kB/s |  86 kB     00:08
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                                          6.0 MB/s |  54 MB     00:08
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                                       1/1
  Installing       : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                                                                                     1/55
  Installing       : mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                             2/55
  Installing       : mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                                    3/55
  Installing       : mysql-errmsg-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                             4/55
  Installing       : perl-Digest-1.17-395.el8.noarch                                                                                                                                      5/55
  Installing       : perl-Digest-MD5-2.55-396.el8.x86_64                                                                                                                                  6/55
  Installing       : perl-Data-Dumper-2.167-399.el8.x86_64                                                                                                                                7/55
  Installing       : perl-libnet-3.11-3.el8.noarch                                                                                                                                        8/55
  Installing       : perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                                                                                                            9/55
  Installing       : perl-URI-1.73-3.el8.noarch                                                                                                                                          10/55
  Installing       : perl-Pod-Escapes-1:1.07-395.el8.noarch                                                                                                                              11/55
  Installing       : perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                                                                                                       12/55
  Installing       : perl-IO-Socket-IP-0.39-5.el8.noarch                                                                                                                                 13/55
  Installing       : perl-Time-Local-1:1.280-1.el8.noarch                                                                                                                                14/55
  Installing       : perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                                                                                                       15/55
  Installing       : perl-Term-ANSIColor-4.06-396.el8.noarch                                                                                                                             16/55
  Installing       : perl-Term-Cap-1.17-395.el8.noarch                                                                                                                                   17/55
  Installing       : perl-File-Temp-0.230.600-1.el8.noarch                                                                                                                               18/55
  Installing       : perl-Pod-Simple-1:3.35-395.el8.noarch                                                                                                                               19/55
  Installing       : perl-HTTP-Tiny-0.074-1.el8.noarch                                                                                                                                   20/55
  Installing       : perl-podlators-4.11-1.el8.noarch                                                                                                                                    21/55
  Installing       : perl-Pod-Perldoc-3.28-396.el8.noarch                                                                                                                                22/55
  Installing       : perl-Text-ParseWords-3.30-395.el8.noarch                                                                                                                            23/55
  Installing       : perl-Pod-Usage-4:1.69-395.el8.noarch                                                                                                                                24/55
  Installing       : perl-MIME-Base64-3.15-396.el8.x86_64                                                                                                                                25/55
  Installing       : perl-Storable-1:3.11-3.el8.x86_64                                                                                                                                   26/55
  Installing       : perl-Getopt-Long-1:2.50-4.el8.noarch                                                                                                                                27/55
  Installing       : perl-Errno-1.28-420.el8.x86_64                                                                                                                                      28/55
  Installing       : perl-Socket-4:2.027-3.el8.x86_64                                                                                                                                    29/55
  Installing       : perl-Encode-4:2.97-3.el8.x86_64                                                                                                                                     30/55
  Installing       : perl-Carp-1.42-396.el8.noarch                                                                                                                                       31/55
  Installing       : perl-Exporter-5.72-396.el8.noarch                                                                                                                                   32/55
  Installing       : perl-libs-4:5.26.3-420.el8.x86_64                                                                                                                                   33/55
  Installing       : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                                                                                                          34/55
  Installing       : perl-parent-1:0.237-1.el8.noarch                                                                                                                                    35/55
  Installing       : perl-macros-4:5.26.3-420.el8.x86_64                                                                                                                                 36/55
  Installing       : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                                                                                                        37/55
  Installing       : perl-Unicode-Normalize-1.25-396.el8.x86_64                                                                                                                          38/55
  Installing       : perl-File-Path-2.15-2.el8.noarch                                                                                                                                    39/55
  Installing       : perl-IO-1.38-420.el8.x86_64                                                                                                                                         40/55
  Installing       : perl-PathTools-3.74-1.el8.x86_64                                                                                                                                    41/55
  Installing       : perl-constant-1.33-396.el8.noarch                                                                                                                                   42/55
  Installing       : perl-threads-1:2.21-2.el8.x86_64                                                                                                                                    43/55
  Installing       : perl-threads-shared-1.58-2.el8.x86_64                                                                                                                               44/55
  Installing       : perl-interpreter-4:5.26.3-420.el8.x86_64                                                                                                                            45/55
  Installing       : python3-setools-4.3.0-2.el8.x86_64                                                                                                                                  46/55
  Installing       : python3-libsemanage-2.9-6.el8.x86_64                                                                                                                                47/55
  Installing       : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                                                                                48/55
  Installing       : libaio-0.3.112-1.el8.x86_64                                                                                                                                         49/55
  Installing       : checkpolicy-2.9-1.el8.x86_64                                                                                                                                        50/55
  Installing       : python3-policycoreutils-2.9-16.el8.noarch                                                                                                                           51/55
  Installing       : policycoreutils-python-utils-2.9-16.el8.noarch                                                                                                                      52/55
  Installing       : protobuf-lite-3.5.0-13.el8.x86_64                                                                                                                                   53/55
  Installing       : mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64                                                                                                                  54/55
  Running scriptlet: mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64                                                                                                                  54/55
  Running scriptlet: mysql-server-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                            55/55
  Installing       : mysql-server-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                            55/55
  Running scriptlet: mysql-server-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                            55/55
ValueError: File context for /var/log/mysql(/.*)? already defined

  Verifying        : mariadb-connector-c-config-3.1.11-2.el8_3.noarch                                                                                                                     1/55
  Verifying        : mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64                                                                                                                   2/55
  Verifying        : mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                                    3/55
  Verifying        : mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                             4/55
  Verifying        : mysql-errmsg-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                             5/55
  Verifying        : mysql-server-8.0.26-1.module_el8.4.0+915+de215114.x86_64                                                                                                             6/55
  Verifying        : perl-Digest-1.17-395.el8.noarch                                                                                                                                      7/55
  Verifying        : perl-Digest-MD5-2.55-396.el8.x86_64                                                                                                                                  8/55
  Verifying        : perl-IO-Socket-IP-0.39-5.el8.noarch                                                                                                                                  9/55
  Verifying        : perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch                                                                                                       10/55
  Verifying        : perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch                                                                                                       11/55
  Verifying        : perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64                                                                                                           12/55
  Verifying        : perl-URI-1.73-3.el8.noarch                                                                                                                                          13/55
  Verifying        : perl-libnet-3.11-3.el8.noarch                                                                                                                                       14/55
  Verifying        : protobuf-lite-3.5.0-13.el8.x86_64                                                                                                                                   15/55
  Verifying        : checkpolicy-2.9-1.el8.x86_64                                                                                                                                        16/55
  Verifying        : libaio-0.3.112-1.el8.x86_64                                                                                                                                         17/55
  Verifying        : perl-Carp-1.42-396.el8.noarch                                                                                                                                       18/55
  Verifying        : perl-Data-Dumper-2.167-399.el8.x86_64                                                                                                                               19/55
  Verifying        : perl-Encode-4:2.97-3.el8.x86_64                                                                                                                                     20/55
  Verifying        : perl-Errno-1.28-420.el8.x86_64                                                                                                                                      21/55
  Verifying        : perl-Exporter-5.72-396.el8.noarch                                                                                                                                   22/55
  Verifying        : perl-File-Path-2.15-2.el8.noarch                                                                                                                                    23/55
  Verifying        : perl-File-Temp-0.230.600-1.el8.noarch                                                                                                                               24/55
  Verifying        : perl-Getopt-Long-1:2.50-4.el8.noarch                                                                                                                                25/55
  Verifying        : perl-HTTP-Tiny-0.074-1.el8.noarch                                                                                                                                   26/55
  Verifying        : perl-IO-1.38-420.el8.x86_64                                                                                                                                         27/55
  Verifying        : perl-MIME-Base64-3.15-396.el8.x86_64                                                                                                                                28/55
  Verifying        : perl-PathTools-3.74-1.el8.x86_64                                                                                                                                    29/55
  Verifying        : perl-Pod-Escapes-1:1.07-395.el8.noarch                                                                                                                              30/55
  Verifying        : perl-Pod-Perldoc-3.28-396.el8.noarch                                                                                                                                31/55
  Verifying        : perl-Pod-Simple-1:3.35-395.el8.noarch                                                                                                                               32/55
  Verifying        : perl-Pod-Usage-4:1.69-395.el8.noarch                                                                                                                                33/55
  Verifying        : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                                                                                                                          34/55
  Verifying        : perl-Socket-4:2.027-3.el8.x86_64                                                                                                                                    35/55
  Verifying        : perl-Storable-1:3.11-3.el8.x86_64                                                                                                                                   36/55
  Verifying        : perl-Term-ANSIColor-4.06-396.el8.noarch                                                                                                                             37/55
  Verifying        : perl-Term-Cap-1.17-395.el8.noarch                                                                                                                                   38/55
  Verifying        : perl-Text-ParseWords-3.30-395.el8.noarch                                                                                                                            39/55
  Verifying        : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                                                                                                                        40/55
  Verifying        : perl-Time-Local-1:1.280-1.el8.noarch                                                                                                                                41/55
  Verifying        : perl-Unicode-Normalize-1.25-396.el8.x86_64                                                                                                                          42/55
  Verifying        : perl-constant-1.33-396.el8.noarch                                                                                                                                   43/55
  Verifying        : perl-interpreter-4:5.26.3-420.el8.x86_64                                                                                                                            44/55
  Verifying        : perl-libs-4:5.26.3-420.el8.x86_64                                                                                                                                   45/55
  Verifying        : perl-macros-4:5.26.3-420.el8.x86_64                                                                                                                                 46/55
  Verifying        : perl-parent-1:0.237-1.el8.noarch                                                                                                                                    47/55
  Verifying        : perl-podlators-4.11-1.el8.noarch                                                                                                                                    48/55
  Verifying        : perl-threads-1:2.21-2.el8.x86_64                                                                                                                                    49/55
  Verifying        : perl-threads-shared-1.58-2.el8.x86_64                                                                                                                               50/55
  Verifying        : policycoreutils-python-utils-2.9-16.el8.noarch                                                                                                                      51/55
  Verifying        : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                                                                                                                52/55
  Verifying        : python3-libsemanage-2.9-6.el8.x86_64                                                                                                                                53/55
  Verifying        : python3-policycoreutils-2.9-16.el8.noarch                                                                                                                           54/55
  Verifying        : python3-setools-4.3.0-2.el8.x86_64                                                                                                                                  55/55

Installed:
  checkpolicy-2.9-1.el8.x86_64                                     libaio-0.3.112-1.el8.x86_64                                 mariadb-connector-c-config-3.1.11-2.el8_3.noarch
  mecab-0.996-1.module_el8.4.0+589+11e12751.9.x86_64               mysql-8.0.26-1.module_el8.4.0+915+de215114.x86_64           mysql-common-8.0.26-1.module_el8.4.0+915+de215114.x86_64
  mysql-errmsg-8.0.26-1.module_el8.4.0+915+de215114.x86_64         mysql-server-8.0.26-1.module_el8.4.0+915+de215114.x86_64    perl-Carp-1.42-396.el8.noarch
  perl-Data-Dumper-2.167-399.el8.x86_64                            perl-Digest-1.17-395.el8.noarch                             perl-Digest-MD5-2.55-396.el8.x86_64
  perl-Encode-4:2.97-3.el8.x86_64                                  perl-Errno-1.28-420.el8.x86_64                              perl-Exporter-5.72-396.el8.noarch
  perl-File-Path-2.15-2.el8.noarch                                 perl-File-Temp-0.230.600-1.el8.noarch                       perl-Getopt-Long-1:2.50-4.el8.noarch
  perl-HTTP-Tiny-0.074-1.el8.noarch                                perl-IO-1.38-420.el8.x86_64                                 perl-IO-Socket-IP-0.39-5.el8.noarch
  perl-IO-Socket-SSL-2.066-4.module_el8.3.0+410+ff426aa3.noarch    perl-MIME-Base64-3.15-396.el8.x86_64                        perl-Mozilla-CA-20160104-7.module_el8.3.0+416+dee7bcef.noarch
  perl-Net-SSLeay-1.88-1.module_el8.3.0+410+ff426aa3.x86_64        perl-PathTools-3.74-1.el8.x86_64                            perl-Pod-Escapes-1:1.07-395.el8.noarch
  perl-Pod-Perldoc-3.28-396.el8.noarch                             perl-Pod-Simple-1:3.35-395.el8.noarch                       perl-Pod-Usage-4:1.69-395.el8.noarch
  perl-Scalar-List-Utils-3:1.49-2.el8.x86_64                       perl-Socket-4:2.027-3.el8.x86_64                            perl-Storable-1:3.11-3.el8.x86_64
  perl-Term-ANSIColor-4.06-396.el8.noarch                          perl-Term-Cap-1.17-395.el8.noarch                           perl-Text-ParseWords-3.30-395.el8.noarch
  perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch                     perl-Time-Local-1:1.280-1.el8.noarch                        perl-URI-1.73-3.el8.noarch
  perl-Unicode-Normalize-1.25-396.el8.x86_64                       perl-constant-1.33-396.el8.noarch                           perl-interpreter-4:5.26.3-420.el8.x86_64
  perl-libnet-3.11-3.el8.noarch                                    perl-libs-4:5.26.3-420.el8.x86_64                           perl-macros-4:5.26.3-420.el8.x86_64
  perl-parent-1:0.237-1.el8.noarch                                 perl-podlators-4.11-1.el8.noarch                            perl-threads-1:2.21-2.el8.x86_64
  perl-threads-shared-1.58-2.el8.x86_64                            policycoreutils-python-utils-2.9-16.el8.noarch              protobuf-lite-3.5.0-13.el8.x86_64
  python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64             python3-libsemanage-2.9-6.el8.x86_64                        python3-policycoreutils-2.9-16.el8.noarch
  python3-setools-4.3.0-2.el8.x86_64

Complete!

6.配置

[root@ecs-218624 ~]# vim /etc/my.cnf

#
# This group is read both both by the client and the server
# use it for options that affect everything
#
[client-server]

#
# include all files from the config directory
#
!includedir /etc/my.cnf.d

要修改的配置添加在/etc/my.cnf.d路径下

[root@ecs-218624 ~]# cd /etc/my.cnf.d
[root@ecs-218624 my.cnf.d]# ls -a
.  ..  client.cnf  mysql-default-authentication-plugin.cnf  mysql-server.cnf

在mysql-server.cnf中添加配置

[root@ecs-218624 my.cnf.d]# vim mysql-server.cnf

#
# This group are read by MySQL server.
# Use it for options that only the server (but not clients) should see
#
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/en/server-configuration-defaults.html

# Settings user and group are ignored when systemd is used.
# If you need to run mysqld under a different user or group,
# customize your systemd unit file for mysqld according to the
# instructions in http://fedoraproject.org/wiki/Systemd

[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
log-error=/var/log/mysql/mysqld.log
pid-file=/run/mysqld/mysqld.pid
lower_case_table_names=1

7.启动服务

[root@ecs-218624 my.cnf.d]# systemctl start mysqld.service
[root@ecs-218624 my.cnf.d]# systemctl status mysqld.service
● mysqld.service - MySQL 8.0 database server
   Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset: disabled)
   Active: active (running) since Sun 2023-01-29 20:20:02 CST; 16s ago
  Process: 8940 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, status=0/SUCCESS)
  Process: 8812 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (code=exited, status=0/SUCCESS)
  Process: 8787 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status=0/SUCCESS)
 Main PID: 8894 (mysqld)
   Status: "Server is operational"
    Tasks: 38 (limit: 23712)
   Memory: 463.3M
   CGroup: /system.slice/mysqld.service
           └─8894 /usr/libexec/mysqld --basedir=/usr

Jan 29 20:19:56 ecs-218624 systemd[1]: Starting MySQL 8.0 database server...
Jan 29 20:19:56 ecs-218624 mysql-prepare-db-dir[8812]: Initializing MySQL database
Jan 29 20:20:02 ecs-218624 systemd[1]: Started MySQL 8.0 database server.

8.修改密码

初始无密码

[root@ecs-218624 my.cnf.d]# grep "password" /var/log/mysql/mysqld.log
2023-01-29T12:19:58.348204Z 6 [Warning] [MY-010453] [Server] root@localhost is created with an empty password ! Please consider switching off the --initialize-insecure option.

直接登录

[root@ecs-218624 my.cnf.d]# mysql -uroot -p

修改密码

mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY '新密码';
Query OK, 0 rows affected (0.00 sec)

修改成功

[root@ecs-218624 my.cnf.d]# mysql -uroot -p
Enter password:
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

9.开启防火墙

[root@ecs-218624 my.cnf.d]# systemctl start firewalld.service
[root@ecs-218624 my.cnf.d]# systemctl status firewalld.service
● firewalld.service - firewalld - dynamic firewall daemon
   Loaded: loaded (/usr/lib/systemd/system/firewalld.service; disabled; vendor preset: enabled)
   Active: active (running) since Sun 2023-01-29 20:32:43 CST; 16s ago

10.开放端口

[root@ecs-218624 my.cnf.d]# firewall-cmd --permanent --zone=public --add-port=3306/tcp
success

11.创建访问客户

mysql> create user 'tester'@'%' identified by '123456';
Query OK, 0 rows affected (0.00 sec)
mysql> grant all on home.* to 'tester'@'%';
Query OK, 0 rows affected (0.01 sec)

12.修改安全组配置,开放3306端口

 

13.其他主机登录

PS C:\Users\cxp-0> mysql -h *.*.221.1 -P3306 -utester -p123456
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 18
Server version: 8.0.26 Source distribution

Copyright (c) 2000, 2022, Oracle and/or its affiliates.

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.

  • 0
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值