AnolisOS 8 MySQL8 二进制安装配置

环境准备:
机器配置:

mysql8单机安装
1、二进制安装:
2、编辑配置文件:
3、初始化数据库:
4、配置环境变量:
5、制作启动文件:
6、用初始密码进入mysql,修改初始密码:
7、一些问题及解决办法

环境准备:

操作系统:Anolis OS 8.4
mysql版本:mysql 8.0.30
mha版本:0.58
1、二进制安装:

查看 之前是否安装过mariadb 或者 mysql

rpm -qa | grep mariadb
rpm -pa | grep mysql

如果有则卸载

rpm -e mariadb-libs-5.5.52-1.el7.x86_64 --nodeps 

再次检查

rpm -qa | grep mariadb
rpm -pa | grep mysql

下载地址 https://dev.mysql.com/downloads/mysql/
备用地址 http://mirrors.163.com/mysql/Downloads/MySQL-8.0/

mkdir -p /data/mysql8
cd /data/mysql8/

上传mysql-8.0.30-el7-x86_64.tar到/data/mysql8/下并解压

tar -xvf  mysql-8.0.30-el7-x86_64.tar
[root@anolis mysql8]# tar -xvf  mysql-8.0.30-el7-x86_64.tar
mysql-test-8.0.30-el7-x86_64.tar.gz
mysql-8.0.30-el7-x86_64.tar.gz
mysql-router-8.0.30-el7-x86_64.tar.gz
[root@anolis mysql8]# ll
total 1601660
-rw-r--r-- 1 root root  820043264 Oct 10 16:33 mysql-8.0.30-el7-x86_64.tar
-rw-r--r-- 1 7161 31415 492490461 Jul  7 06:44 mysql-8.0.30-el7-x86_64.tar.gz
-rw-r--r-- 1 7161 31415  22006040 Jul  7 06:42 mysql-router-8.0.30-el7-x86_64.tar.gz
-rw-r--r-- 1 7161 31415 305543348 Jul  7 06:43 mysql-test-8.0.30-el7-x86_64.tar.gz

[root@anolis mysql8]# tar -zxvf  mysql-8.0.30-el7-x86_64.tar.gz 
mysql-8.0.30-el7-x86_64/bin/
mysql-8.0.30-el7-x86_64/bin/myisam_ftdump
mysql-8.0.30-el7-x86_64/bin/myisamchk
mysql-8.0.30-el7-x86_64/bin/myisamlog
mysql-8.0.30-el7-x86_64/bin/myisampack
mysql-8.0.30-el7-x86_64/bin/mysql
mysql-8.0.30-el7-x86_64/bin/mysql_config_editor
mysql-8.0.30-el7-x86_64/bin/mysql_migrate_keyring
mysql-8.0.30-el7-x86_64/bin/mysql_secure_installation
... ...
mysql-8.0.30-el7-x86_64/lib/private/sasl2/libscram.so.3
mysql-8.0.30-el7-x86_64/lib/private/sasl2/libscram.so.3.0.0
mysql-8.0.30-el7-x86_64/share/
mysql-8.0.30-el7-x86_64/share/install_rewriter.sql
mysql-8.0.30-el7-x86_64/share/uninstall_rewriter.sql

[root@anolis mysql8]# ll
drwxr-xr-x 9 root root       4096 Oct 10 17:16 mysql-8.0.30-el7-x86_64

[root@anolis mysql8]# ll mysql-8.0.30-el7-x86_64
total 316
drwxr-xr-x  2 7161 31415   4096 Jul  7 06:44 bin
drwxr-xr-x  2 7161 31415   4096 Jul  7 06:44 docs
drwxr-xr-x  3 7161 31415   4096 Jul  7 06:44 include
drwxr-xr-x  6 7161 31415   4096 Jul  7 06:44 lib
-rw-r--r--  1 7161 31415 287624 Jul  7 05:36 LICENSE
drwxr-xr-x  4 7161 31415   4096 Jul  7 06:44 man
-rw-r--r--  1 7161 31415    666 Jul  7 05:36 README
drwxr-xr-x 28 7161 31415   4096 Jul  7 06:44 share
drwxr-xr-x  2 7161 31415   4096 Jul  7 06:44 support-files

[root@anolis mysql8]# mv mysql-8.0.30-el7-x86_64    /usr/local/mysql8

[root@anolis mysql8]# ll /usr/local/
total 60
drwxr-xr-x   7 root root 4096 Oct  5 17:52 aegis
drwxr-xr-x.  2 root root 4096 Oct 10 15:44 bin
drwxr-xr-x.  2 root root 4096 Sep 27 10:07 etc
drwxr-xr-x.  2 root root 4096 Jan 18  2022 games
drwxr-xr-x.  2 root root 4096 Jan 18  2022 include
drwxr-xr-x   8   10  143 4096 Jun 17  2014 jdk1.8.0_11
drwxr-xr-x.  3 root root 4096 Oct 10 15:43 lib
drwxr-xr-x.  4 root root 4096 Oct 10 15:43 lib64
drwxr-xr-x.  2 root root 4096 Sep 27 10:07 libexec
drwxr-xr-x   9 root root 4096 Oct 10 17:16 mysql8
drwxr-xr-x  11 root root 4096 Oct  5 16:02 nginx
drwxr-xr-x   7 root root 4096 Oct  5 17:50 redis
drwxr-xr-x.  2 root root 4096 Sep 27 10:07 sbin
drwxr-xr-x.  8 root root 4096 Oct 10 15:43 share
drwxr-xr-x.  4 root root 4096 Oct  5 17:44 src
安装epel源
rpm -Uvh --force --nodeps https://kojipkgs.fedoraproject.org/packages/epel-release/8/17.el8/noarch/epel-release-8-17.el8.noarch.rpm
查看epel源是否生效
dnf repolist all     #列出所有的存储库
Repository epel is listed more than once in the configuration
仓库 id                        仓库名称                                   状态
AppStream           AnolisOS-8 - AppStream   启用
BaseOS              AnolisOS-8 - BaseOS      启用
DDE                 AnolisOS-8 - DDE         禁用
Plus                AnolisOS-8 - Plus        禁用
PowerTools          AnolisOS-8 - PowerTools  启用
epel                epel                     禁用
epel-debuginfo      Extra Packages for Enterprise Linux 8 - x86_64 - Debug          禁用
epel-source         Extra Packages for Enterprise Linux 8 - x86_64 - Source         禁用
epel-testing        Extra Packages for Enterprise Linux 8 - Testing - x86_64        禁用
epel-testing-debuginfo  Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Debug    禁用
epel-testing-source     Extra Packages for Enterprise Linux 8 - Testing - x86_64 - Source   禁用
nginx-mainline           nginx mainline repo                                                禁用
nginx-stable             nginx stable repo                                                  启用
启用epel源
dnf config-manager --set-enable epel   #启用epel源
dnf repolist epel      #查看epel源的状态
Repository epel is listed more than once in the configuration
仓库 id                            仓库名称                          状态
epel                               epel                            启用
清理缓存,并重新拉取元数据缓存
# dnf clean all  
Repository epel is listed more than once in the configuration
45 文件已删除
[root@anolis ~]# dnf makecache
Repository epel is listed more than once in the configuration
AnolisOS-8 - AppStream                          622 kB/s | 9.3 MB     00:15    
AnolisOS-8 - BaseOS                             8.3 MB/s | 6.6 MB     00:00    
epel                                            198 kB/s |  13 MB     01:06    
AnolisOS-8 - PowerTools                         6.5 MB/s | 2.1 MB     00:00    
nginx stable repo                               43 kB/s |  43 kB     00:00    
元数据缓存已建立。
安装依赖
[root@anolis mysql8]# dnf -y install perl  net-tools
Last metadata expiration check: 1:41:46 ago on Mon 10 Oct 2022 03:47:55 PM CST.
Package net-tools-2.0-0.52.20160912git.an8.x86_64 is already installed.
Dependencies resolved.
============================================================================================================================================================================
 Package                                              Architecture                   Version                                        Repository                         Size
============================================================================================================================================================================
Installing:
 perl                                                 x86_64                         4:5.26.3-421.0.1.an8                           AppStream                          72 k
Installing dependencies:
 perl-Algorithm-Diff                                  noarch                         1.1903-9.0.1.an8                               BaseOS                             41 k
 perl-Archive-Tar                                     noarch                         2.30-1.0.1.an8                                 BaseOS                             69 k
 perl-Archive-Zip                                     noarch                         1.60-3.el8                                     AppStream                         107 k
 perl-Attribute-Handlers                              noarch                         0.99-421.0.1.an8                               AppStream                          88 k
 perl-B-Debug                                         noarch                         1.26-2.0.1.an8                                 AppStream                          21 k
 perl-CPAN                                            noarch                         2.18-397.0.1.an8                               AppStream                         285 k
 perl-Compress-Bzip2                                  x86_64                         2.26-6.0.1.an8                                 AppStream                          66 k
 perl-Config-Perl-V                                   noarch                         0.30-1.0.1.an8                                 AppStream                          18 k
 perl-DB_File                                         x86_64                         1.842-1.0.1.an8                                AppStream                          68 k
 perl-Data-Section                                    noarch                         0.200007-3.el8                                 AppStream                          29 k
 perl-Devel-PPPort                                    x86_64                         3.36-5.0.1.an8                                 AppStream                         100 k
 perl-Devel-Peek                                      x86_64                         1.26-421.0.1.an8                               AppStream                          93 k
 perl-Devel-SelfStubber                               noarch                         1.06-421.0.1.an8                               AppStream                          75 k
 perl-Devel-Size                                      x86_64                         0.81-2.0.1.an8                                 AppStream                          29 k
 perl-Encode-devel                                    x86_64                         4:2.97-3.el8                                   AppStream                          38 k
 perl-Env                                             noarch                         1.04-395.0.1.an8                               AppStream                          20 k
 perl-ExtUtils-CBuilder                               noarch                         1:0.280230-2.0.1.an8                           AppStream                          41 k
 perl-ExtUtils-Embed                                  noarch                         1.34-421.0.1.an8                               AppStream                          78 k
 perl-ExtUtils-MM-Utils                               noarch                         1:7.34-1.0.1.an8                               AppStream                          16 k
 perl-ExtUtils-Miniperl                               noarch                         1.06-421.0.1.an8                               AppStream                          76 k
 perl-File-Fetch                                      noarch                         0.56-2.0.1.an8                                 AppStream                          29 k
 perl-File-HomeDir                                    noarch                         1.002-4.0.1.an8                                AppStream                          55 k
 perl-File-Which                                      noarch                         1.22-2.0.1.an8                                 AppStream                          19 k
 perl-Filter                                          x86_64                         2:1.58-2.0.1.an8                               AppStream                          71 k
 perl-Filter-Simple                                   noarch                         0.94-2.0.1.an8                                 AppStream                          24 k
 perl-IO-Zlib                                         noarch                         1:1.10-421.0.1.an8                             BaseOS                             80 k
 perl-IPC-Cmd                                         noarch                         2:1.02-1.0.1.an8                               AppStream                          38 k
 perl-IPC-SysV                                        x86_64                         2.07-397.0.1.an8                               AppStream                          35 k
 perl-Locale-Codes                                    noarch                         3.57-1.0.1.an8                                 AppStream                         303 k
 perl-Locale-Maketext                                 noarch                         1.28-396.0.1.an8                               AppStream                          94 k
 perl-Locale-Maketext-Simple                          noarch                         1:0.21-421.0.1.an8                             AppStream                          78 k
 perl-MRO-Compat                                      noarch                         0.13-4.0.1.an8                                 AppStream                          20 k
 perl-Math-BigInt-FastCalc                            x86_64                         0.500.600-6.0.1.an8                            AppStream                          20 k
 perl-Math-BigRat                                     noarch                         0.2614-1.0.1.an8                               AppStream                          32 k
 perl-Memoize                                         noarch                         1.03-421.0.1.an8                               AppStream                         118 k
 perl-Module-Build                                    noarch                         2:0.42.24-5.0.1.an8                            AppStream                         220 k
 perl-Module-CoreList                                 noarch                         1:5.20181130-1.0.1.an8                         AppStream                          81 k
 perl-Module-CoreList-tools                           noarch                         1:5.20181130-1.0.1.an8                         AppStream                          20 k
 perl-Module-Load                                     noarch                         1:0.32-395.0.1.an8                             AppStream                          16 k
 perl-Module-Load-Conditional                         noarch                         0.68-395.0.1.an8                               AppStream                          21 k
 perl-Module-Loaded                                   noarch                         1:0.08-421.0.1.an8                             AppStream                          74 k
 perl-Module-Metadata                                 noarch                         1.000033-395.0.1.an8                           AppStream                          39 k
 perl-Net-Ping                                        noarch                         2.55-421.0.1.an8                               AppStream                         101 k
 perl-Params-Check                                    noarch                         1:0.38-395.0.1.an8                             AppStream                          21 k
 perl-Perl-OSType                                     noarch                         1.010-396.0.1.an8                              AppStream                          25 k
 perl-PerlIO-via-QuotedPrint                          noarch                         0.08-395.0.1.an8                               AppStream                          11 k
 perl-Pod-Checker                                     noarch                         4:1.73-395.0.1.an8                             AppStream                          29 k
 perl-Pod-Html                                        noarch                         1.22.02-421.0.1.an8                            AppStream                          87 k
 perl-Pod-Parser                                      noarch                         1.63-396.0.1.an8                               AppStream                          91 k
 perl-SelfLoader                                      noarch                         1.23-421.0.1.an8                               AppStream                          82 k
 perl-Software-License                                noarch                         0.103013-2.0.1.an8                             AppStream                         135 k
 perl-Sys-Syslog                                      x86_64                         0.35-397.0.1.an8                               AppStream                          42 k
 perl-Test                                            noarch                         1.30-421.0.1.an8                               AppStream                          89 k
 perl-Text-Balanced                                   noarch                         2.03-395.0.1.an8                               AppStream                          48 k
 perl-Text-Diff                                       noarch                         1.45-2.0.1.an8                                 BaseOS                             41 k
 perl-Text-Glob                                       noarch                         0.11-4.0.1.an8                                 AppStream                          15 k
 perl-Text-Template                                   noarch                         1.51-1.0.1.an8                                 AppStream                          63 k
 perl-Unicode-Collate                                 x86_64                         1.25-2.0.1.an8                                 AppStream                         676 k
 perl-bignum                                          noarch                         0.49-2.0.1.an8                                 AppStream                          38 k
 perl-encoding                                        x86_64                         4:2.22-3.el8                                   AppStream                          67 k
 perl-experimental                                    noarch                         0.019-2.0.1.an8                                AppStream                          21 k
 perl-inc-latest                                      noarch                         2:0.500-9.0.1.an8                              AppStream                          23 k
 perl-libnetcfg                                       noarch                         4:5.26.3-421.0.1.an8                           AppStream                          77 k
 perl-local-lib                                       noarch                         2.000024-2.0.1.an8                             AppStream                          68 k
 perl-open                                            noarch                         1.11-421.0.1.an8                               AppStream                          77 k
 perl-perlfaq                                         noarch                         5.20180605-1.0.1.an8                           AppStream                         382 k
 perl-utils                                           noarch                         5.26.3-421.0.1.an8                             AppStream                         128 k
Installing weak dependencies:
 perl-TermReadKey                                     x86_64                         2.37-7.0.1.an8                                 AppStream                          33 k

Transaction Summary
============================================================================================================================================================================
Install  69 Packages

Total download size: 5.3 M
Installed size: 14 M
Downloading Packages:
(1/69): perl-Archive-Zip-1.60-3.el8.noarch.rpm                                                                                              1.2 MB/s | 107 kB     00:00    
(2/69): perl-Attribute-Handlers-0.99-421.0.1.an8.noarch.rpm                                                                                 946 kB/s |  88 kB     00:00    
(3/69): perl-5.26.3-421.0.1.an8.x86_64.rpm                                                                                                  716 kB/s |  72 kB     00:00    
(4/69): perl-B-Debug-1.26-2.0.1.an8.noarch.rpm                                                                                              307 kB/s |  21 kB     00:00    
(5/69): perl-Compress-Bzip2-2.26-6.0.1.an8.x86_64.rpm                                                                                       953 kB/s |  66 kB     00:00    
(6/69): perl-CPAN-2.18-397.0.1.an8.noarch.rpm                                                                                               3.1 MB/s | 285 kB     00:00    
(7/69): perl-DB_File-1.842-1.0.1.an8.x86_64.rpm                                                                                             953 kB/s |  68 kB     00:00    
(8/69): perl-Config-Perl-V-0.30-1.0.1.an8.noarch.rpm                                                                                        214 kB/s |  18 kB     00:00    
(9/69): perl-Data-Section-0.200007-3.el8.noarch.rpm                                                                                         448 kB/s |  29 kB     00:00    
(10/69): perl-Devel-PPPort-3.36-5.0.1.an8.x86_64.rpm                                                                                        1.1 MB/s | 100 kB     00:00    
(11/69): perl-Devel-Peek-1.26-421.0.1.an8.x86_64.rpm                                                                                        1.1 MB/s |  93 kB     00:00    
(12/69): perl-Devel-SelfStubber-1.06-421.0.1.an8.noarch.rpm                                                                                 904 kB/s |  75 kB     00:00    
(13/69): perl-Env-1.04-395.0.1.an8.noarch.rpm                                                                                               304 kB/s |  20 kB     00:00    
(14/69): perl-Devel-Size-0.81-2.0.1.an8.x86_64.rpm                                                                                          390 kB/s |  29 kB     00:00    
(15/69): perl-Encode-devel-2.97-3.el8.x86_64.rpm                                                                                            467 kB/s |  38 kB     00:00    
(16/69): perl-ExtUtils-CBuilder-0.280230-2.0.1.an8.noarch.rpm                                                                               600 kB/s |  41 kB     00:00    
(17/69): perl-ExtUtils-Embed-1.34-421.0.1.an8.noarch.rpm                                                                                    952 kB/s |  78 kB     00:00    
(18/69): perl-ExtUtils-MM-Utils-7.34-1.0.1.an8.noarch.rpm                                                                                   165 kB/s |  16 kB     00:00    
(19/69): perl-ExtUtils-Miniperl-1.06-421.0.1.an8.noarch.rpm                                                                                 816 kB/s |  76 kB     00:00    
(20/69): perl-File-Fetch-0.56-2.0.1.an8.noarch.rpm                                                                                          359 kB/s |  29 kB     00:00    
(21/69): perl-File-HomeDir-1.002-4.0.1.an8.noarch.rpm                                                                                       792 kB/s |  55 kB     00:00    
(22/69): perl-File-Which-1.22-2.0.1.an8.noarch.rpm                                                                                          254 kB/s |  19 kB     00:00    
(23/69): perl-Filter-1.58-2.0.1.an8.x86_64.rpm                                                                                              945 kB/s |  71 kB     00:00    
(24/69): perl-Filter-Simple-0.94-2.0.1.an8.noarch.rpm                                                                                       356 kB/s |  24 kB     00:00    
(25/69): perl-IPC-SysV-2.07-397.0.1.an8.x86_64.rpm                                                                                          479 kB/s |  35 kB     00:00    
(26/69): perl-Locale-Codes-3.57-1.0.1.an8.noarch.rpm                                                                                        3.7 MB/s | 303 kB     00:00    
(27/69): perl-IPC-Cmd-1.02-1.0.1.an8.noarch.rpm                                                                                             434 kB/s |  38 kB     00:00    
(28/69): perl-Locale-Maketext-1.28-396.0.1.an8.noarch.rpm                                                                                   1.3 MB/s |  94 kB     00:00    
(29/69): perl-MRO-Compat-0.13-4.0.1.an8.noarch.rpm                                                                                          262 kB/s |  20 kB     00:00    
(30/69): perl-Locale-Maketext-Simple-0.21-421.0.1.an8.noarch.rpm                                                                            947 kB/s |  78 kB     00:00    
(31/69): perl-Math-BigRat-0.2614-1.0.1.an8.noarch.rpm                                                                                       520 kB/s |  32 kB     00:00    
(32/69): perl-Math-BigInt-FastCalc-0.500.600-6.0.1.an8.x86_64.rpm                                                                           262 kB/s |  20 kB     00:00    
(33/69): perl-Memoize-1.03-421.0.1.an8.noarch.rpm                                                                                           1.6 MB/s | 118 kB     00:00    
(34/69): perl-Module-CoreList-5.20181130-1.0.1.an8.noarch.rpm                                                                               1.1 MB/s |  81 kB     00:00    
(35/69): perl-Module-Build-0.42.24-5.0.1.an8.noarch.rpm                                                                                     2.5 MB/s | 220 kB     00:00    
(36/69): perl-Module-CoreList-tools-5.20181130-1.0.1.an8.noarch.rpm                                                                         246 kB/s |  20 kB     00:00    
(37/69): perl-Module-Load-Conditional-0.68-395.0.1.an8.noarch.rpm                                                                           306 kB/s |  21 kB     00:00    
(38/69): perl-Module-Load-0.32-395.0.1.an8.noarch.rpm                                                                                       199 kB/s |  16 kB     00:00    
(39/69): perl-Module-Loaded-0.08-421.0.1.an8.noarch.rpm                                                                                     897 kB/s |  74 kB     00:00    
(40/69): perl-Module-Metadata-1.000033-395.0.1.an8.noarch.rpm                                                                               608 kB/s |  39 kB     00:00    
(41/69): perl-Net-Ping-2.55-421.0.1.an8.noarch.rpm                                                                                          1.2 MB/s | 101 kB     00:00    
(42/69): perl-Params-Check-0.38-395.0.1.an8.noarch.rpm                                                                                      314 kB/s |  21 kB     00:00    
(43/69): perl-Perl-OSType-1.010-396.0.1.an8.noarch.rpm                                                                                      393 kB/s |  25 kB     00:00    
(44/69): perl-Pod-Checker-1.73-395.0.1.an8.noarch.rpm                                                                                       419 kB/s |  29 kB     00:00    
(45/69): perl-PerlIO-via-QuotedPrint-0.08-395.0.1.an8.noarch.rpm                                                                            149 kB/s |  11 kB     00:00    
(46/69): perl-Pod-Html-1.22.02-421.0.1.an8.noarch.rpm                                                                                       907 kB/s |  87 kB     00:00    
(47/69): perl-SelfLoader-1.23-421.0.1.an8.noarch.rpm                                                                                        1.2 MB/s |  82 kB     00:00    
(48/69): perl-Pod-Parser-1.63-396.0.1.an8.noarch.rpm                                                                                        1.2 MB/s |  91 kB     00:00    
(49/69): perl-Sys-Syslog-0.35-397.0.1.an8.x86_64.rpm                                                                                        613 kB/s |  42 kB     00:00    
(50/69): perl-Software-License-0.103013-2.0.1.an8.noarch.rpm                                                                                1.6 MB/s | 135 kB     00:00    
(51/69): perl-TermReadKey-2.37-7.0.1.an8.x86_64.rpm                                                                                         343 kB/s |  33 kB     00:00    
(52/69): perl-Test-1.30-421.0.1.an8.noarch.rpm                                                                                              1.2 MB/s |  89 kB     00:00    
(53/69): perl-Text-Balanced-2.03-395.0.1.an8.noarch.rpm                                                                                     605 kB/s |  48 kB     00:00    
(54/69): perl-Text-Glob-0.11-4.0.1.an8.noarch.rpm                                                                                           194 kB/s |  15 kB     00:00    
(55/69): perl-Text-Template-1.51-1.0.1.an8.noarch.rpm                                                                                       675 kB/s |  63 kB     00:00    
(56/69): perl-Unicode-Collate-1.25-2.0.1.an8.x86_64.rpm                                                                                     6.8 MB/s | 676 kB     00:00    
(57/69): perl-bignum-0.49-2.0.1.an8.noarch.rpm                                                                                              474 kB/s |  38 kB     00:00    
(58/69): perl-encoding-2.22-3.el8.x86_64.rpm                                                                                                802 kB/s |  67 kB     00:00    
(59/69): perl-experimental-0.019-2.0.1.an8.noarch.rpm                                                                                       313 kB/s |  21 kB     00:00    
(60/69): perl-inc-latest-0.500-9.0.1.an8.noarch.rpm                                                                                         282 kB/s |  23 kB     00:00    
(61/69): perl-libnetcfg-5.26.3-421.0.1.an8.noarch.rpm                                                                                       1.1 MB/s |  77 kB     00:00    
(62/69): perl-local-lib-2.000024-2.0.1.an8.noarch.rpm                                                                                       858 kB/s |  68 kB     00:00    
(63/69): perl-open-1.11-421.0.1.an8.noarch.rpm                                                                                              1.1 MB/s |  77 kB     00:00    
(64/69): perl-perlfaq-5.20180605-1.0.1.an8.noarch.rpm                                                                                       4.0 MB/s | 382 kB     00:00    
(65/69): perl-utils-5.26.3-421.0.1.an8.noarch.rpm                                                                                           1.5 MB/s | 128 kB     00:00    
(66/69): perl-Algorithm-Diff-1.1903-9.0.1.an8.noarch.rpm                                                                                    484 kB/s |  41 kB     00:00    
(67/69): perl-IO-Zlib-1.10-421.0.1.an8.noarch.rpm                                                                                           1.0 MB/s |  80 kB     00:00    
(68/69): perl-Archive-Tar-2.30-1.0.1.an8.noarch.rpm                                                                                         736 kB/s |  69 kB     00:00    
(69/69): perl-Text-Diff-1.45-2.0.1.an8.noarch.rpm                                                                                           507 kB/s |  41 kB     00:00    
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Total                                                                                                                                       2.9 MB/s | 5.3 MB     00:01     
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
  Preparing        :                                                                                                                                                    1/1 
  Installing       : perl-SelfLoader-1.23-421.0.1.an8.noarch                                                                                                           1/69 
  Installing       : perl-Perl-OSType-1.010-396.0.1.an8.noarch                                                                                                         2/69 
  Installing       : perl-Module-Metadata-1.000033-395.0.1.an8.noarch                                                                                                  3/69 
  Installing       : perl-Module-Load-1:0.32-395.0.1.an8.noarch                                                                                                        4/69 
  Installing       : perl-Module-CoreList-1:5.20181130-1.0.1.an8.noarch                                                                                                5/69 
  Installing       : perl-Filter-2:1.58-2.0.1.an8.x86_64                                                                                                               6/69 
  Installing       : perl-encoding-4:2.22-3.el8.x86_64                                                                                                                 7/69 
  Installing       : perl-Text-Balanced-2.03-395.0.1.an8.noarch                                                                                                        8/69 
  Installing       : perl-IO-Zlib-1:1.10-421.0.1.an8.noarch                                                                                                            9/69 
  Installing       : perl-Pod-Html-1.22.02-421.0.1.an8.noarch                                                                                                         10/69 
  Installing       : perl-Net-Ping-2.55-421.0.1.an8.noarch                                                                                                            11/69 
  Installing       : perl-Math-BigRat-0.2614-1.0.1.an8.noarch                                                                                                         12/69 
  Installing       : perl-Locale-Maketext-1.28-396.0.1.an8.noarch                                                                                                     13/69 
  Installing       : perl-Locale-Maketext-Simple-1:0.21-421.0.1.an8.noarch                                                                                            14/69 
  Installing       : perl-Params-Check-1:0.38-395.0.1.an8.noarch                                                                                                      15/69 
  Installing       : perl-Module-Load-Conditional-0.68-395.0.1.an8.noarch                                                                                             16/69 
  Installing       : perl-ExtUtils-Embed-1.34-421.0.1.an8.noarch                                                                                                      17/69 
  Installing       : perl-ExtUtils-Miniperl-1.06-421.0.1.an8.noarch                                                                                                   18/69 
  Installing       : perl-bignum-0.49-2.0.1.an8.noarch                                                                                                                19/69 
  Installing       : perl-Filter-Simple-0.94-2.0.1.an8.noarch                                                                                                         20/69 
  Installing       : perl-open-1.11-421.0.1.an8.noarch                                                                                                                21/69 
  Installing       : perl-Module-CoreList-tools-1:5.20181130-1.0.1.an8.noarch                                                                                         22/69 
  Installing       : perl-Devel-SelfStubber-1.06-421.0.1.an8.noarch                                                                                                   23/69 
  Installing       : perl-Algorithm-Diff-1.1903-9.0.1.an8.noarch                                                                                                      24/69 
  Installing       : perl-Text-Diff-1.45-2.0.1.an8.noarch                                                                                                             25/69 
  Installing       : perl-Archive-Tar-2.30-1.0.1.an8.noarch                                                                                                           26/69 
  Installing       : perl-utils-5.26.3-421.0.1.an8.noarch                                                                                                             27/69 
  Installing       : perl-perlfaq-5.20180605-1.0.1.an8.noarch                                                                                                         28/69 
  Installing       : perl-local-lib-2.000024-2.0.1.an8.noarch                                                                                                         29/69 
  Installing       : perl-libnetcfg-4:5.26.3-421.0.1.an8.noarch                                                                                                       30/69 
  Installing       : perl-inc-latest-2:0.500-9.0.1.an8.noarch                                                                                                         31/69 
  Installing       : perl-experimental-0.019-2.0.1.an8.noarch                                                                                                         32/69 
  Installing       : perl-Unicode-Collate-1.25-2.0.1.an8.x86_64                                                                                                       33/69 
  Installing       : perl-Text-Template-1.51-1.0.1.an8.noarch                                                                                                         34/69 
  Installing       : perl-Text-Glob-0.11-4.0.1.an8.noarch                                                                                                             35/69 
  Installing       : perl-Test-1.30-421.0.1.an8.noarch                                                                                                                36/69 
  Installing       : perl-TermReadKey-2.37-7.0.1.an8.x86_64                                                                                                           37/69 
  Installing       : perl-Sys-Syslog-0.35-397.0.1.an8.x86_64                                                                                                          38/69 
  Installing       : perl-Pod-Parser-1.63-396.0.1.an8.noarch                                                                                                          39/69 
  Installing       : perl-Pod-Checker-4:1.73-395.0.1.an8.noarch                                                                                                       40/69 
  Installing       : perl-PerlIO-via-QuotedPrint-0.08-395.0.1.an8.noarch                                                                                              41/69 
  Installing       : perl-Module-Loaded-1:0.08-421.0.1.an8.noarch                                                                                                     42/69 
  Installing       : perl-Memoize-1.03-421.0.1.an8.noarch                                                                                                             43/69 
  Installing       : perl-Math-BigInt-FastCalc-0.500.600-6.0.1.an8.x86_64                                                                                             44/69 
  Installing       : perl-MRO-Compat-0.13-4.0.1.an8.noarch                                                                                                            45/69 
  Installing       : perl-Data-Section-0.200007-3.el8.noarch                                                                                                          46/69 
  Installing       : perl-Software-License-0.103013-2.0.1.an8.noarch                                                                                                  47/69 
  Installing       : perl-Locale-Codes-3.57-1.0.1.an8.noarch                                                                                                          48/69 
  Installing       : perl-IPC-SysV-2.07-397.0.1.an8.x86_64                                                                                                            49/69 
  Installing       : perl-File-Which-1.22-2.0.1.an8.noarch                                                                                                            50/69 
  Installing       : perl-File-HomeDir-1.002-4.0.1.an8.noarch                                                                                                         51/69 
  Installing       : perl-ExtUtils-MM-Utils-1:7.34-1.0.1.an8.noarch                                                                                                   52/69 
  Installing       : perl-IPC-Cmd-2:1.02-1.0.1.an8.noarch                                                                                                             53/69 
  Installing       : perl-ExtUtils-CBuilder-1:0.280230-2.0.1.an8.noarch                                                                                               54/69 
  Installing       : perl-Module-Build-2:0.42.24-5.0.1.an8.noarch                                                                                                     55/69 
  Installing       : perl-File-Fetch-0.56-2.0.1.an8.noarch                                                                                                            56/69 
  Installing       : perl-Env-1.04-395.0.1.an8.noarch                                                                                                                 57/69 
  Installing       : perl-Encode-devel-4:2.97-3.el8.x86_64                                                                                                            58/69 
  Installing       : perl-Devel-Size-0.81-2.0.1.an8.x86_64                                                                                                            59/69 
  Installing       : perl-Devel-Peek-1.26-421.0.1.an8.x86_64                                                                                                          60/69 
  Installing       : perl-Devel-PPPort-3.36-5.0.1.an8.x86_64                                                                                                          61/69 
  Installing       : perl-DB_File-1.842-1.0.1.an8.x86_64                                                                                                              62/69 
  Installing       : perl-Config-Perl-V-0.30-1.0.1.an8.noarch                                                                                                         63/69 
  Installing       : perl-Compress-Bzip2-2.26-6.0.1.an8.x86_64                                                                                                        64/69 
  Installing       : perl-B-Debug-1.26-2.0.1.an8.noarch                                                                                                               65/69 
  Installing       : perl-Attribute-Handlers-0.99-421.0.1.an8.noarch                                                                                                  66/69 
  Installing       : perl-Archive-Zip-1.60-3.el8.noarch                                                                                                               67/69 
  Installing       : perl-CPAN-2.18-397.0.1.an8.noarch                                                                                                                68/69 
  Installing       : perl-4:5.26.3-421.0.1.an8.x86_64                                                                                                                 69/69 
  Running scriptlet: perl-4:5.26.3-421.0.1.an8.x86_64                                                                                                                 69/69 
  Verifying        : perl-4:5.26.3-421.0.1.an8.x86_64                                                                                                                  1/69 
  Verifying        : perl-Archive-Zip-1.60-3.el8.noarch                                                                                                                2/69 
  Verifying        : perl-Attribute-Handlers-0.99-421.0.1.an8.noarch                                                                                                   3/69 
  Verifying        : perl-B-Debug-1.26-2.0.1.an8.noarch                                                                                                                4/69 
  Verifying        : perl-CPAN-2.18-397.0.1.an8.noarch                                                                                                                 5/69 
  Verifying        : perl-Compress-Bzip2-2.26-6.0.1.an8.x86_64                                                                                                         6/69 
  Verifying        : perl-Config-Perl-V-0.30-1.0.1.an8.noarch                                                                                                          7/69 
  Verifying        : perl-DB_File-1.842-1.0.1.an8.x86_64                                                                                                               8/69 
  Verifying        : perl-Data-Section-0.200007-3.el8.noarch                                                                                                           9/69 
  Verifying        : perl-Devel-PPPort-3.36-5.0.1.an8.x86_64                                                                                                          10/69 
  Verifying        : perl-Devel-Peek-1.26-421.0.1.an8.x86_64                                                                                                          11/69 
  Verifying        : perl-Devel-SelfStubber-1.06-421.0.1.an8.noarch                                                                                                   12/69 
  Verifying        : perl-Devel-Size-0.81-2.0.1.an8.x86_64                                                                                                            13/69 
  Verifying        : perl-Encode-devel-4:2.97-3.el8.x86_64                                                                                                            14/69 
  Verifying        : perl-Env-1.04-395.0.1.an8.noarch                                                                                                                 15/69 
  Verifying        : perl-ExtUtils-CBuilder-1:0.280230-2.0.1.an8.noarch                                                                                               16/69 
  Verifying        : perl-ExtUtils-Embed-1.34-421.0.1.an8.noarch                                                                                                      17/69 
  Verifying        : perl-ExtUtils-MM-Utils-1:7.34-1.0.1.an8.noarch                                                                                                   18/69 
  Verifying        : perl-ExtUtils-Miniperl-1.06-421.0.1.an8.noarch                                                                                                   19/69 
  Verifying        : perl-File-Fetch-0.56-2.0.1.an8.noarch                                                                                                            20/69 
  Verifying        : perl-File-HomeDir-1.002-4.0.1.an8.noarch                                                                                                         21/69 
  Verifying        : perl-File-Which-1.22-2.0.1.an8.noarch                                                                                                            22/69 
  Verifying        : perl-Filter-2:1.58-2.0.1.an8.x86_64                                                                                                              23/69 
  Verifying        : perl-Filter-Simple-0.94-2.0.1.an8.noarch                                                                                                         24/69 
  Verifying        : perl-IPC-Cmd-2:1.02-1.0.1.an8.noarch                                                                                                             25/69 
  Verifying        : perl-IPC-SysV-2.07-397.0.1.an8.x86_64                                                                                                            26/69 
  Verifying        : perl-Locale-Codes-3.57-1.0.1.an8.noarch                                                                                                          27/69 
  Verifying        : perl-Locale-Maketext-1.28-396.0.1.an8.noarch                                                                                                     28/69 
  Verifying        : perl-Locale-Maketext-Simple-1:0.21-421.0.1.an8.noarch                                                                                            29/69 
  Verifying        : perl-MRO-Compat-0.13-4.0.1.an8.noarch                                                                                                            30/69 
  Verifying        : perl-Math-BigInt-FastCalc-0.500.600-6.0.1.an8.x86_64                                                                                             31/69 
  Verifying        : perl-Math-BigRat-0.2614-1.0.1.an8.noarch                                                                                                         32/69 
  Verifying        : perl-Memoize-1.03-421.0.1.an8.noarch                                                                                                             33/69 
  Verifying        : perl-Module-Build-2:0.42.24-5.0.1.an8.noarch                                                                                                     34/69 
  Verifying        : perl-Module-CoreList-1:5.20181130-1.0.1.an8.noarch                                                                                               35/69 
  Verifying        : perl-Module-CoreList-tools-1:5.20181130-1.0.1.an8.noarch                                                                                         36/69 
  Verifying        : perl-Module-Load-1:0.32-395.0.1.an8.noarch                                                                                                       37/69 
  Verifying        : perl-Module-Load-Conditional-0.68-395.0.1.an8.noarch                                                                                             38/69 
  Verifying        : perl-Module-Loaded-1:0.08-421.0.1.an8.noarch                                                                                                     39/69 
  Verifying        : perl-Module-Metadata-1.000033-395.0.1.an8.noarch                                                                                                 40/69 
  Verifying        : perl-Net-Ping-2.55-421.0.1.an8.noarch                                                                                                            41/69 
  Verifying        : perl-Params-Check-1:0.38-395.0.1.an8.noarch                                                                                                      42/69 
  Verifying        : perl-Perl-OSType-1.010-396.0.1.an8.noarch                                                                                                        43/69 
  Verifying        : perl-PerlIO-via-QuotedPrint-0.08-395.0.1.an8.noarch                                                                                              44/69 
  Verifying        : perl-Pod-Checker-4:1.73-395.0.1.an8.noarch                                                                                                       45/69 
  Verifying        : perl-Pod-Html-1.22.02-421.0.1.an8.noarch                                                                                                         46/69 
  Verifying        : perl-Pod-Parser-1.63-396.0.1.an8.noarch                                                                                                          47/69 
  Verifying        : perl-SelfLoader-1.23-421.0.1.an8.noarch                                                                                                          48/69 
  Verifying        : perl-Software-License-0.103013-2.0.1.an8.noarch                                                                                                  49/69 
  Verifying        : perl-Sys-Syslog-0.35-397.0.1.an8.x86_64                                                                                                          50/69 
  Verifying        : perl-TermReadKey-2.37-7.0.1.an8.x86_64                                                                                                           51/69 
  Verifying        : perl-Test-1.30-421.0.1.an8.noarch                                                                                                                52/69 
  Verifying        : perl-Text-Balanced-2.03-395.0.1.an8.noarch                                                                                                       53/69 
  Verifying        : perl-Text-Glob-0.11-4.0.1.an8.noarch                                                                                                             54/69 
  Verifying        : perl-Text-Template-1.51-1.0.1.an8.noarch                                                                                                         55/69 
  Verifying        : perl-Unicode-Collate-1.25-2.0.1.an8.x86_64                                                                                                       56/69 
  Verifying        : perl-bignum-0.49-2.0.1.an8.noarch                                                                                                                57/69 
  Verifying        : perl-encoding-4:2.22-3.el8.x86_64                                                                                                                58/69 
  Verifying        : perl-experimental-0.019-2.0.1.an8.noarch                                                                                                         59/69 
  Verifying        : perl-inc-latest-2:0.500-9.0.1.an8.noarch                                                                                                         60/69 
  Verifying        : perl-libnetcfg-4:5.26.3-421.0.1.an8.noarch                                                                                                       61/69 
  Verifying        : perl-local-lib-2.000024-2.0.1.an8.noarch                                                                                                         62/69 
  Verifying        : perl-open-1.11-421.0.1.an8.noarch                                                                                                                63/69 
  Verifying        : perl-perlfaq-5.20180605-1.0.1.an8.noarch                                                                                                         64/69 
  Verifying        : perl-utils-5.26.3-421.0.1.an8.noarch                                                                                                             65/69 
  Verifying        : perl-Algorithm-Diff-1.1903-9.0.1.an8.noarch                                                                                                      66/69 
  Verifying        : perl-Archive-Tar-2.30-1.0.1.an8.noarch                                                                                                           67/69 
  Verifying        : perl-IO-Zlib-1:1.10-421.0.1.an8.noarch                                                                                                           68/69 
  Verifying        : perl-Text-Diff-1.45-2.0.1.an8.noarch                                                                                                             69/69 

Installed:
  perl-4:5.26.3-421.0.1.an8.x86_64                       perl-Algorithm-Diff-1.1903-9.0.1.an8.noarch             perl-Archive-Tar-2.30-1.0.1.an8.noarch                    
  perl-Archive-Zip-1.60-3.el8.noarch                     perl-Attribute-Handlers-0.99-421.0.1.an8.noarch         perl-B-Debug-1.26-2.0.1.an8.noarch                        
  perl-CPAN-2.18-397.0.1.an8.noarch                      perl-Compress-Bzip2-2.26-6.0.1.an8.x86_64               perl-Config-Perl-V-0.30-1.0.1.an8.noarch                  
  perl-DB_File-1.842-1.0.1.an8.x86_64                    perl-Data-Section-0.200007-3.el8.noarch                 perl-Devel-PPPort-3.36-5.0.1.an8.x86_64                   
  perl-Devel-Peek-1.26-421.0.1.an8.x86_64                perl-Devel-SelfStubber-1.06-421.0.1.an8.noarch          perl-Devel-Size-0.81-2.0.1.an8.x86_64                     
  perl-Encode-devel-4:2.97-3.el8.x86_64                  perl-Env-1.04-395.0.1.an8.noarch                        perl-ExtUtils-CBuilder-1:0.280230-2.0.1.an8.noarch        
  perl-ExtUtils-Embed-1.34-421.0.1.an8.noarch            perl-ExtUtils-MM-Utils-1:7.34-1.0.1.an8.noarch          perl-ExtUtils-Miniperl-1.06-421.0.1.an8.noarch            
  perl-File-Fetch-0.56-2.0.1.an8.noarch                  perl-File-HomeDir-1.002-4.0.1.an8.noarch                perl-File-Which-1.22-2.0.1.an8.noarch                     
  perl-Filter-2:1.58-2.0.1.an8.x86_64                    perl-Filter-Simple-0.94-2.0.1.an8.noarch                perl-IO-Zlib-1:1.10-421.0.1.an8.noarch                    
  perl-IPC-Cmd-2:1.02-1.0.1.an8.noarch                   perl-IPC-SysV-2.07-397.0.1.an8.x86_64                   perl-Locale-Codes-3.57-1.0.1.an8.noarch                   
  perl-Locale-Maketext-1.28-396.0.1.an8.noarch           perl-Locale-Maketext-Simple-1:0.21-421.0.1.an8.noarch   perl-MRO-Compat-0.13-4.0.1.an8.noarch                     
  perl-Math-BigInt-FastCalc-0.500.600-6.0.1.an8.x86_64   perl-Math-BigRat-0.2614-1.0.1.an8.noarch                perl-Memoize-1.03-421.0.1.an8.noarch                      
  perl-Module-Build-2:0.42.24-5.0.1.an8.noarch           perl-Module-CoreList-1:5.20181130-1.0.1.an8.noarch      perl-Module-CoreList-tools-1:5.20181130-1.0.1.an8.noarch  
  perl-Module-Load-1:0.32-395.0.1.an8.noarch             perl-Module-Load-Conditional-0.68-395.0.1.an8.noarch    perl-Module-Loaded-1:0.08-421.0.1.an8.noarch              
  perl-Module-Metadata-1.000033-395.0.1.an8.noarch       perl-Net-Ping-2.55-421.0.1.an8.noarch                   perl-Params-Check-1:0.38-395.0.1.an8.noarch               
  perl-Perl-OSType-1.010-396.0.1.an8.noarch              perl-PerlIO-via-QuotedPrint-0.08-395.0.1.an8.noarch     perl-Pod-Checker-4:1.73-395.0.1.an8.noarch                
  perl-Pod-Html-1.22.02-421.0.1.an8.noarch               perl-Pod-Parser-1.63-396.0.1.an8.noarch                 perl-SelfLoader-1.23-421.0.1.an8.noarch                   
  perl-Software-License-0.103013-2.0.1.an8.noarch        perl-Sys-Syslog-0.35-397.0.1.an8.x86_64                 perl-TermReadKey-2.37-7.0.1.an8.x86_64                    
  perl-Test-1.30-421.0.1.an8.noarch                      perl-Text-Balanced-2.03-395.0.1.an8.noarch              perl-Text-Diff-1.45-2.0.1.an8.noarch                      
  perl-Text-Glob-0.11-4.0.1.an8.noarch                   perl-Text-Template-1.51-1.0.1.an8.noarch                perl-Unicode-Collate-1.25-2.0.1.an8.x86_64                
  perl-bignum-0.49-2.0.1.an8.noarch                      perl-encoding-4:2.22-3.el8.x86_64                       perl-experimental-0.019-2.0.1.an8.noarch                  
  perl-inc-latest-2:0.500-9.0.1.an8.noarch               perl-libnetcfg-4:5.26.3-421.0.1.an8.noarch              perl-local-lib-2.000024-2.0.1.an8.noarch                  
  perl-open-1.11-421.0.1.an8.noarch                      perl-perlfaq-5.20180605-1.0.1.an8.noarch                perl-utils-5.26.3-421.0.1.an8.noarch                      

Complete!
创建用户和用户组
groupadd mysql
useradd -g mysql mysql
创建mysql的数据、日志等数据存储目录
[root@anolis mysql8]# pwd
/data/mysql8

[root@anolis mysql8]# mkdir {data,log,var}
[root@anolis mysql8]# ll
total 12
drwxr-xr-x 2 root root 4096 Oct 11 10:24 data
drwxr-xr-x 2 root root 4096 Oct 11 10:24 log
drwxr-xr-x 2 root root 4096 Oct 11 10:24 var
授权
chown -R mysql:mysql  /data/mysql8/
chown -R mysql:mysql  /usr/local/mysql8/

[root@anolis mysql8]# ll /data/mysql8
total 12
drwxr-xr-x 2 mysql mysql 4096 Oct 11 10:24 data
drwxr-xr-x 2 mysql mysql 4096 Oct 11 10:24 log
drwxr-xr-x 2 mysql mysql 4096 Oct 11 10:24 var

[root@anolis mysql8]# ll /usr/local/mysql8
total 316
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 bin
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 docs
drwxr-xr-x  3 mysql mysql   4096 Jul  7 06:44 include
drwxr-xr-x  6 mysql mysql   4096 Jul  7 06:44 lib
-rw-r--r--  1 mysql mysql 287624 Jul  7 05:36 LICENSE
drwxr-xr-x  4 mysql mysql   4096 Jul  7 06:44 man
-rw-r--r--  1 mysql mysql    666 Jul  7 05:36 README
drwxr-xr-x 28 mysql mysql   4096 Jul  7 06:44 share
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 support-files

2、编辑配置文件:

注意默认可能有/etc/my.cnf存在,备份 cp /etc/my.cnf /etc/my.cnf_back

[root@anolis mysql8]# ll /etc/my*
ls: cannot access '/etc/my*': No such file or directory

在设置mysql数据库新密码前先不要在配置文件中设置“skip-name-resolve” 否则会报“Host ‘127.0.0.1’ is not allowed to connect to this MySQL server”解决办法就是先暂时注释掉这一条,设置好密码后再删除注释符号。


# vim /usr/local/mysql8/my.cnf

配置文件内容如下
[mysql]
default-character-set=utf8mb4
socket=/data/mysql8/var/mysql.sock

[mysqld]
port=3306
socket=/data/mysql8/var/mysql.sock
basedir=/usr/local/mysql8
datadir=/data/mysql8/data
lower_case_table_names=1
server-id=161
log-bin=/data/mysql8/data/mysql-bin
relay_log=relay_bin
log_slave_updates=on
pid-file=/data/mysql8/var/mysqld.pid
gtid_mode=on
enforce_gtid_consistency=on
binlog_format=row

skip-name-resolve
character-set-server=utf8mb4
collation-server=utf8mb4_general_ci
character-set-client-handshake=FALSE
#symbolic-links=0  #mysql8默认禁用符号软连接
sql_mode='STRICT_TRANS_TABLES,NO_ZERO_IN_DATE,NO_ZERO_DATE,ERROR_FOR_DIVISION_BY_ZERO,NO_ENGINE_SUBSTITUTION'

max_connections=200
max_connect_errors=1000
max_allowed_packet=200M

default-storage-engine=INNODB
innodb_buffer_pool_size=200M

#explicit_defaults_for_timestamp=1
log-output=FILE
slow_query_log=ON
slow_query_log_file=/data/mysql8/log/slow.log
long_query_time=5
log-error=/data/mysql8/log/liandodb_error.log
default-authentication-plugin=mysql_native_password

[client]
port= 3306
default-character-set=utf8mb4
socket=/data/mysql8/var/mysql.sock

3、初始化数据库:

  • 注意:--lower-case-table-names=1
  • MySQL8.0 新增了data dictionary的概念,数据初始化的时候在linux下默认使用lower-case-table-names=0的参数,数据库启动的时候读取的my.cnf文件中的值。若二者值不一致则在mysql的错误日志中记录报错信息。在MySQL 5.7之前则允许数据库初始化和启动的值不一致且以启动值为准。在MySQL 官方提供的RPM包中默认是使用lower-case-table-names=0,不太适合生产环境部署。在生产环境建议使用官方的二进制包。
  • 解决办法:
    在mysql数据库初始化的时候指定不区分大小写,在数据库实例启动的时候也要指定不区分大小写。即数据库初始化时lower_case_table_names的值和数据库启动时的值需要一样。
    在实际开发生产的应用中多是不区分大小写的即lower-case-table-names=1。
$ mysqld --initialize --lower-case-table-names=1 --user=mysql --basedir=/usr/local/mysql8 --datadir=/data/mysql8/data
配置文件中添加如下设置
my.cnf
 [mysqld]
 lower_case_table_names=1
数据库初始化
[root@anolis mysql8]# cd /usr/local/mysql8/
[root@anolis mysql8]# ll
total 320
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 bin
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 docs
drwxr-xr-x  3 mysql mysql   4096 Jul  7 06:44 include
drwxr-xr-x  6 mysql mysql   4096 Jul  7 06:44 lib
-rw-r--r--  1 mysql mysql 287624 Jul  7 05:36 LICENSE
drwxr-xr-x  4 mysql mysql   4096 Jul  7 06:44 man
-rw-r--r--  1 root  root    1124 Oct 11 10:40 my.cnf
-rw-r--r--  1 mysql mysql    666 Jul  7 05:36 README
drwxr-xr-x 28 mysql mysql   4096 Jul  7 06:44 share
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 support-files
[root@anolis mysql8]# chown -R mysql:mysql  /usr/local/mysql8/
[root@anolis mysql8]# ll
total 320
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 bin
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 docs
drwxr-xr-x  3 mysql mysql   4096 Jul  7 06:44 include
drwxr-xr-x  6 mysql mysql   4096 Jul  7 06:44 lib
-rw-r--r--  1 mysql mysql 287624 Jul  7 05:36 LICENSE
drwxr-xr-x  4 mysql mysql   4096 Jul  7 06:44 man
-rw-r--r--  1 mysql mysql   1124 Oct 11 10:40 my.cnf
-rw-r--r--  1 mysql mysql    666 Jul  7 05:36 README
drwxr-xr-x 28 mysql mysql   4096 Jul  7 06:44 share
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 support-files

# su mysql
[mysql@anolis mysql8]$ mysqld --initialize --lower-case-table-names=1 --user=mysql --basedir=/usr/local/mysql8 --datadir=/data/mysql8/data
bash: mysqld: command not found
[mysql@anolis mysql8]$ ll 
total 320
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 bin
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 docs
drwxr-xr-x  3 mysql mysql   4096 Jul  7 06:44 include
drwxr-xr-x  6 mysql mysql   4096 Jul  7 06:44 lib
-rw-r--r--  1 mysql mysql 287624 Jul  7 05:36 LICENSE
drwxr-xr-x  4 mysql mysql   4096 Jul  7 06:44 man
-rw-r--r--  1 mysql mysql   1124 Oct 11 10:40 my.cnf
-rw-r--r--  1 mysql mysql    666 Jul  7 05:36 README
drwxr-xr-x 28 mysql mysql   4096 Jul  7 06:44 share
drwxr-xr-x  2 mysql mysql   4096 Jul  7 06:44 support-files
[mysql@anolis mysql8]$ ll bin/
total 645192
-rwxr-xr-x 1 mysql mysql    838543 Jul  7 06:26 ibd2sdi
-rwxr-xr-x 1 mysql mysql    627297 Jul  7 06:26 innochecksum
-rwxr-xr-x 1 mysql mysql    423030 Jul  7 06:25 lz4_decompress
-rwxr-xr-x 1 mysql mysql   7457514 Jul  7 06:26 myisamchk
-rwxr-xr-x 1 mysql mysql   7190337 Jul  7 06:26 myisam_ftdump
-rwxr-xr-x 1 mysql mysql   7153603 Jul  7 06:26 myisamlog
-rwxr-xr-x 1 mysql mysql   7277060 Jul  7 06:26 myisampack
-rwxr-xr-x 1 mysql mysql    523164 Jul  7 06:25 my_print_defaults
-rwxr-xr-x 1 mysql mysql   8727346 Jul  7 06:28 mysql
-rwxr-xr-x 1 mysql mysql   8281507 Jul  7 06:27 mysqladmin
-rwxr-xr-x 1 mysql mysql   9136483 Jul  7 06:28 mysqlbinlog
-rwxr-xr-x 1 mysql mysql   8304186 Jul  7 06:27 mysqlcheck
-rwxr-xr-x 1 mysql mysql      5085 Jul  7 06:24 mysql_config
-rwxr-xr-x 1 mysql mysql    517722 Jul  7 06:27 mysql_config_editor
-rwxr-xr-x 1 mysql mysql 124663507 Jul  7 06:36 mysqld
-rwxr-xr-x 1 mysql mysql 398569041 Jul  7 06:22 mysqld-debug
-rwxr-xr-x 1 mysql mysql     27492 Jul  7 06:24 mysqld_multi
-rwxr-xr-x 1 mysql mysql     29183 Jul  7 06:24 mysqld_safe
-rwxr-xr-x 1 mysql mysql   8397779 Jul  7 06:27 mysqldump
-rwxr-xr-x 1 mysql mysql      7669 Jul  7 06:24 mysqldumpslow
-rwxr-xr-x 1 mysql mysql   8272892 Jul  7 06:27 mysqlimport
-rwxr-xr-x 1 mysql mysql   8546008 Jul  7 06:28 mysql_migrate_keyring
-rwxr-xr-x 1 mysql mysql   9621311 Jul  7 06:28 mysqlpump
-rwxr-xr-x 1 mysql mysql   8257156 Jul  7 06:27 mysql_secure_installation
-rwxr-xr-x 1 mysql mysql   8273197 Jul  7 06:27 mysqlshow
-rwxr-xr-x 1 mysql mysql   8296506 Jul  7 06:27 mysqlslap
-rwxr-xr-x 1 mysql mysql    607088 Jul  7 06:25 mysql_ssl_rsa_setup
-rwxr-xr-x 1 mysql mysql    371143 Jul  7 06:26 mysql_tzinfo_to_sql
-rwxr-xr-x 1 mysql mysql   8556891 Jul  7 06:28 mysql_upgrade
-rwxr-xr-x 1 mysql mysql   1268701 Jul  7 06:26 perror
-rwxr-xr-x 1 mysql mysql    387596 Jul  7 06:25 zlib_decompress
[mysql@anolis mysql8]$ ll bin/mysqld
-rwxr-xr-x 1 mysql mysql 124663507 Jul  7 06:36 bin/mysqld
[mysql@anolis mysql8]$ ./bin/mysqld --initialize --lower-case-table-names=1 --user=mysql --basedir=/usr/local/mysql8 --datadir=/data/mysql8/data
2022-10-11T02:52:58.904186Z 0 [System] [MY-013169] [Server] /usr/local/mysql8/bin/mysqld (mysqld 8.0.30) initializing of server in progress as process 14675
2022-10-11T02:52:58.910401Z 1 [System] [MY-013576] [InnoDB] InnoDB initialization has started.
2022-10-11T02:52:59.560432Z 1 [System] [MY-013577] [InnoDB] InnoDB initialization has ended.
2022-10-11T02:53:00.814714Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: >(t:Wf>XB5d>



# 执行完后生成mysql默认root用户的密码 root@localhost: >(t:Wf>XB5d> 之后登录需要用到这里记录下来。

4、配置环境变量:

vim /etc/profile
# MYSQL8_HOME
MYSQL8_HOME=/usr/local/mysql8
export PATH=$PATH:$MYSQL8_HOME/bin

#刷新使环境变量生效
source /etc/profile

5、制作启动文件:

vim /etc/systemd/system/mysql8d.service

[Unit]
Description=MySQL Server
Documentation=man:mysqld(8)
Documentation=http://dev.mysql.com/doc/refman/en/using-systemd.html
After=network.target
After=syslog.target

[Install]
WantedBy=multi-user.target
[Service]
User=mysql
Group=mysql
ExecStart=/usr/local/mysql8/bin/mysqld --defaults-file=/usr/local/mysql8/my.cnf
LimitNOFILE = 65536
LimitNPROC = 65536

保存退出
重新加载service文件
systemctl daemon-reload
设置开机启动
[root@anolis mysql8]# systemctl enable mysql8d
Created symlink /etc/systemd/system/multi-user.target.wants/mysql8d.service → /etc/systemd/system/mysql8d.service.
日常启停命令
systemctl start mysql8d.service
systemctl status mysql8d.service
systemctl stop mysql8d.service

6、用初始密码进入mysql,修改初始密码:

mysql -u root -p -h 127.0.0.1

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'pass123';

mysql> flush privileges;

mysql> use mysql;

mysql> select host,user from user where user='root';

+-----------+------+
| host      | user |
+-----------+------+
| localhost | root |
+-----------+------+


mysql> update user set host='%',plugin='mysql_native_password' where user='root';

mysql> flush privileges;

mysql> select host,user from user where user='root';

+------+------+
| host | user |
+------+------+
| %    | root |
+------+------+

7、一些问题及解决办法

#问题1、密码失效
    1、修改my.cnf 在[mysqld]段落下增加 skip-grant-tables=1 #登录时,跳过权限验证
    2、update user set authentication_string=MD5('root') where user='root' and Host = 'localhost';
    或者update user set authentication_string=SHA1('root') where user='root' and Host = 'localhost';
    FLUSH PRIVILEGES;
    select host, user, authentication_string, plugin from user;

    如果直接执行ALTER USER报错,可以按下面顺序执行
    update user set host='%',plugin='mysql_native_password',authentication_string='' where user='root';
    FLUSH PRIVILEGES;
    ALTER USER 'root'@'localhost'  IDENTIFIED WITH mysql_native_password BY '123456';

#问题2、 Starting MySQL.2021-02-05T01:43:59.542284Z mysqld_safe Directory '/var/lib/mysql' for UNIX socket file don't exists.
    解决:mkdir /var/lib/mysql
    
#问题3、Starting MySQL... ERROR! The server quit without updating PID file (/data1/mysql8/data/CT-DevOps-DB.pid).
    解决查看错误日志:Could not create unix socket lock file /var/lib/mysql/mysql.sock.lock.
    这个是权限不足导致,设置权限 chown -R mysql:mysql /var/lib/mysql/
    grant all privileges on *.* to 'root'@'%' ;
    
# 问题4、navicate连接不上
    解决:添加需要监听的端口/sbin/iptables -I INPUT -p tcp --dport 3307 -j ACCEPT
    iptables-save > /etc/sysconfig/iptables iptables-save是将规则追加到一个文件

8、设置mysql仅指定的IP段可以访问

mysql> use mysql;
mysql> select host,user from user where user='root';

+------+------+
| host | user |
+------+------+
| %    | root |
+------+------+
mysql> update user set host='172.21.157.%',plugin='mysql_native_password' where user='root';
Query OK, 1 row affected (0.01 sec)
Rows matched: 1  Changed: 1  Warnings: 0

mysql> flush privileges;
Query OK, 0 rows affected (0.01 sec)

mysql> select host,user from user where user='root';
+--------------+------+
| host         | user |
+--------------+------+
| 172.21.157.% | root |
+--------------+------+
1 row in set (0.00 sec)
退出后测试
[root@anolis mysql8]# mysql -u root -p -h 127.0.0.1
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
[root@anolis mysql8]# mysql -u root -p -h 172.21.157.49
Enter password: 
Welcome to the MySQL monitor.  Commands end with ; or \g.
Your MySQL connection id is 10
Server version: 8.0.30 MySQL Community Server - GPL

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.

mysql>

你可能感兴趣的:(AnolisOS 8 MySQL8 二进制安装配置)