zoukankan      html  css  js  c++  java
  • centos 8及以上安装mysql 8.0

    本文适用于centos 8及以上安装mysql 8.0,整体耗时20分钟内,不需要翻墙

    1.环境先搞好

     systemctl stop firewalld    //关闭防火墙
     systemctl disable firewalld    //禁用防火墙
     setenforce 0
     sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config 
     timedatectl set-timezone Asia/Shanghai

    2.开始安装

    yum -y install mysql-server mysql mysql-devel  //快速安装mysql
    mysqld --install --user=root  
    mysqld --initialize --user=mysql
    mysqld --initialize --lower-case-table-names=1
    
    //查看mysql日志,密码在日志中  mysql的安装位置在/var/lib/mysql/
    cat /var/log/mysql/mysqld.log 
    ///发现错误 Data Dictionary initialization failed    

    3.Data Dictionary initialization failed解决办法

      rm -rf /var/lib/mysql
    
      mysqld --initialize --console
    
      chown -R mysql:mysql /var/lib/mysql/
    
      systemctl start mysqld
    
      systemctl status mysqld
    
      cat /var/log/mysql/mysqld.log 
    
      //A temporary password is generated for root@localhost: 冒号后面的就是初始密码

    4.修改密码并开启远程访问

    mysql -u root -p  
    //需要输入初始密码,进入mysql控制台 ALTER USER
    'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test@123'; //修改密码为test@123 use mysql select Host,User from user; update user set host = '%' where user ='root'; //将host从localhost修改为全部 flush privileges; exit

    5.其他操作

    rpm -qa | grep mysql
    
    yum -y remove mysql....  //如果mysql已安装,执行删除
    
    systemctl  enable/start/stop/status servicename   // enable //设置开机启动 ; start  //启动 ; stop  //停止 ;status状态

    6.连接mysql

     

    在虚拟机上的输入输出记录

    Xshell 6 (Build 0189)
    Copyright (c) 2002 NetSarang Computer, Inc. All rights reserved.
    
    Type `help' to learn how to use Xshell prompt.
    [D:~]$ 
    
    Connecting to 192.168.5.133:22...
    Connection established.
    To escape to local shell, press 'Ctrl+Alt+]'.
    
    WARNING! The remote SSH server rejected X11 forwarding request.
    Activate the web console with: systemctl enable --now cockpit.socket
    
    Last login: Tue Sep  1 15:41:10 2020
    [root@localhost ~]# systemctl stop firewalld
    [root@localhost ~]# systemctl disable firewalld
    Removed /etc/systemd/system/multi-user.target.wants/firewalld.service.
    Removed /etc/systemd/system/dbus-org.fedoraproject.FirewallD1.service.
    [root@localhost ~]# setenforce 0
    [root@localhost ~]# sed -i 's/^SELINUX=.*/SELINUX=disabled/' /etc/selinux/config
    [root@localhost ~]# timedatectl set-timezone Asia/Shanghai
    [root@localhost ~]# yum -y install mysql-server mysql mysql-devel
    Last metadata expiration check: 0:11:14 ago on Tue 01 Sep 2020 03:51:03 PM CST.
    Dependencies resolved.
    ===================================================================================
     Package               Arch   Version                              Repo       Size
    ===================================================================================
    Installing:
     mysql                 x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream  11 M
     mysql-devel           x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 147 k
     mysql-server          x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream  22 M
    Installing dependencies:
     checkpolicy           x86_64 2.9-1.el8                            BaseOS    348 k
     keyutils-libs-devel   x86_64 1.5.10-6.el8                         BaseOS     48 k
     krb5-devel            x86_64 1.17-18.el8                          BaseOS    549 k
     libcom_err-devel      x86_64 1.45.4-3.el8                         BaseOS     38 k
     libevent              x86_64 2.1.8-5.el8                          BaseOS    253 k
     libkadm5              x86_64 1.17-18.el8                          BaseOS    185 k
     libselinux-devel      x86_64 2.9-3.el8                            BaseOS    199 k
     libsepol-devel        x86_64 2.9-1.el8                            BaseOS     86 k
     libverto-devel        x86_64 0.3.0-5.el8                          BaseOS     18 k
     mariadb-connector-c-config
                           noarch 3.0.7-1.el8                          AppStream  13 k
     mecab                 x86_64 0.996-1.module_el8.0.0+41+ca30bab6.9 AppStream 397 k
     mysql-common          x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 143 k
     mysql-errmsg          x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 557 k
     mysql-libs            x86_64 8.0.17-3.module_el8.0.0+181+899d6349 AppStream 1.2 M
     openssl-devel         x86_64 1:1.1.1c-15.el8                      BaseOS    2.3 M
     pcre2-devel           x86_64 10.32-1.el8                          BaseOS    605 k
     pcre2-utf16           x86_64 10.32-1.el8                          BaseOS    228 k
     pcre2-utf32           x86_64 10.32-1.el8                          BaseOS    220 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-416.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-416.el8                         BaseOS    141 k
     perl-MIME-Base64      x86_64 3.15-396.el8                         BaseOS     31 k
     perl-Net-SSLeay       x86_64 1.88-1.el8                           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-416.el8                     BaseOS    6.3 M
     perl-libnet           noarch 3.11-3.el8                           AppStream 121 k
     perl-libs             x86_64 4:5.26.3-416.el8                     BaseOS    1.6 M
     perl-macros           x86_64 4:5.26.3-416.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-9.el8                            BaseOS    251 k
     protobuf-lite         x86_64 3.5.0-7.el8                          AppStream 150 k
     python3-audit         x86_64 3.0-0.17.20191104git1c2f876.el8      BaseOS     86 k
     python3-libsemanage   x86_64 2.9-2.el8                            BaseOS    127 k
     python3-policycoreutils
                           noarch 2.9-9.el8                            BaseOS    2.2 M
     python3-setools       x86_64 4.2.2-2.el8                          BaseOS    601 k
     zlib-devel            x86_64 1.2.11-13.el8                        BaseOS     57 k
    Installing weak dependencies:
     perl-IO-Socket-IP     noarch 0.39-5.el8                           AppStream  47 k
     perl-IO-Socket-SSL    noarch 2.066-4.el8                          AppStream 297 k
     perl-Mozilla-CA       noarch 20160104-7.el8                       AppStream  15 k
    Enabling module streams:
     mysql                        8.0                                                 
    
    Transaction Summary
    ===================================================================================
    Install  69 Packages
    
    Total download size: 55 M
    Installed size: 279 M
    Downloading Packages:
    (1/69): mariadb-connector-c-config-3.0.7-1.el8.noa  71 kB/s |  13 kB     00:00    
    [MIRROR] mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm: Curl error (56): Failure when receiving data from the peer for http://mirror.lzu.edu.cn/centos/8.2.2004/AppStream/x86_64/os/Packages/mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm [Recv failure: Connection reset by peer]
    [MIRROR] mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm: Curl error (56): Failure when receiving data from the peer for http://mirror.lzu.edu.cn/centos/8.2.2004/AppStream/x86_64/os/Packages/mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm [Recv failure: Connection reset by peer]
    (2/69): mysql-common-8.0.17-3.module_el8.0.0+181+8 602 kB/s | 143 kB     00:00    
    (3/69): mysql-devel-8.0.17-3.module_el8.0.0+181+89 2.3 MB/s | 147 kB     00:00    
    (4/69): mecab-0.996-1.module_el8.0.0+41+ca30bab6.9 562 kB/s | 397 kB     00:00    
    (5/69): mysql-errmsg-8.0.17-3.module_el8.0.0+181+8 2.5 MB/s | 557 kB     00:00    
    [MIRROR] mysql-libs-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm: Curl error (56): Failure when receiving data from the peer for http://mirror.lzu.edu.cn/centos/8.2.2004/AppStream/x86_64/os/Packages/mysql-libs-8.0.17-3.module_el8.0.0+181+899d6349.x86_64.rpm [Recv failure: Connection reset by peer]
    (6/69): mysql-libs-8.0.17-3.module_el8.0.0+181+899 2.2 MB/s | 1.2 MB     00:00    
    (7/69): perl-Digest-1.17-395.el8.noarch.rpm        379 kB/s |  27 kB     00:00    
    (8/69): perl-Digest-MD5-2.55-396.el8.x86_64.rpm    1.4 MB/s |  37 kB     00:00    
    (9/69): perl-IO-Socket-IP-0.39-5.el8.noarch.rpm    1.5 MB/s |  47 kB     00:00    
    (10/69): perl-IO-Socket-SSL-2.066-4.el8.noarch.rpm 264 kB/s | 297 kB     00:01    
    (11/69): perl-Mozilla-CA-20160104-7.el8.noarch.rpm 413 kB/s |  15 kB     00:00    
    (12/69): perl-Net-SSLeay-1.88-1.el8.x86_64.rpm     3.6 MB/s | 379 kB     00:00    
    (13/69): perl-URI-1.73-3.el8.noarch.rpm            2.8 MB/s | 116 kB     00:00    
    (14/69): perl-libnet-3.11-3.el8.noarch.rpm         3.4 MB/s | 121 kB     00:00    
    (15/69): protobuf-lite-3.5.0-7.el8.x86_64.rpm      4.0 MB/s | 150 kB     00:00    
    (16/69): checkpolicy-2.9-1.el8.x86_64.rpm          831 kB/s | 348 kB     00:00    
    (17/69): keyutils-libs-devel-1.5.10-6.el8.x86_64.r 470 kB/s |  48 kB     00:00    
    (18/69): krb5-devel-1.17-18.el8.x86_64.rpm         1.4 MB/s | 549 kB     00:00    
    (19/69): libcom_err-devel-1.45.4-3.el8.x86_64.rpm  304 kB/s |  38 kB     00:00    
    (20/69): libevent-2.1.8-5.el8.x86_64.rpm           1.6 MB/s | 253 kB     00:00    
    (21/69): libkadm5-1.17-18.el8.x86_64.rpm           1.6 MB/s | 185 kB     00:00    
    (22/69): libselinux-devel-2.9-3.el8.x86_64.rpm     1.7 MB/s | 199 kB     00:00    
    (23/69): libsepol-devel-2.9-1.el8.x86_64.rpm       994 kB/s |  86 kB     00:00    
    (24/69): libverto-devel-0.3.0-5.el8.x86_64.rpm     367 kB/s |  18 kB     00:00    
    (25/69): openssl-devel-1.1.1c-15.el8.x86_64.rpm    2.2 MB/s | 2.3 MB     00:01    
    (26/69): mysql-8.0.17-3.module_el8.0.0+181+899d634 1.9 MB/s |  11 MB     00:05    
    (27/69): mysql-server-8.0.17-3.module_el8.0.0+181+ 4.3 MB/s |  22 MB     00:04    
    (28/69): pcre2-devel-10.32-1.el8.x86_64.rpm        1.8 MB/s | 605 kB     00:00    
    (29/69): perl-Carp-1.42-396.el8.noarch.rpm         442 kB/s |  30 kB     00:00    
    (30/69): pcre2-utf16-10.32-1.el8.x86_64.rpm        678 kB/s | 228 kB     00:00    
    (31/69): perl-Data-Dumper-2.167-399.el8.x86_64.rpm 755 kB/s |  58 kB     00:00    
    (32/69): perl-Errno-1.28-416.el8.x86_64.rpm        557 kB/s |  76 kB     00:00    
    (33/69): pcre2-utf32-10.32-1.el8.x86_64.rpm        631 kB/s | 220 kB     00:00    
    (34/69): perl-Exporter-5.72-396.el8.noarch.rpm     476 kB/s |  34 kB     00:00    
    (35/69): perl-File-Path-2.15-2.el8.noarch.rpm      503 kB/s |  38 kB     00:00    
    (36/69): perl-File-Temp-0.230.600-1.el8.noarch.rpm 580 kB/s |  63 kB     00:00    
    (37/69): perl-Getopt-Long-2.50-4.el8.noarch.rpm    593 kB/s |  63 kB     00:00    
    (38/69): perl-HTTP-Tiny-0.074-1.el8.noarch.rpm     544 kB/s |  58 kB     00:00    
    (39/69): perl-MIME-Base64-3.15-396.el8.x86_64.rpm  377 kB/s |  31 kB     00:00    
    (40/69): perl-IO-1.38-416.el8.x86_64.rpm           738 kB/s | 141 kB     00:00    
    (41/69): perl-Pod-Escapes-1.07-395.el8.noarch.rpm  300 kB/s |  20 kB     00:00    
    (42/69): perl-PathTools-3.74-1.el8.x86_64.rpm      704 kB/s |  90 kB     00:00    
    (43/69): perl-Pod-Perldoc-3.28-396.el8.noarch.rpm  628 kB/s |  86 kB     00:00    
    (44/69): perl-Pod-Usage-1.69-395.el8.noarch.rpm    408 kB/s |  34 kB     00:00    
    (45/69): perl-Pod-Simple-3.35-395.el8.noarch.rpm   763 kB/s | 213 kB     00:00    
    (46/69): perl-Scalar-List-Utils-1.49-2.el8.x86_64. 597 kB/s |  68 kB     00:00    
    (47/69): perl-Socket-2.027-3.el8.x86_64.rpm        572 kB/s |  59 kB     00:00    
    (48/69): perl-Storable-3.11-3.el8.x86_64.rpm       682 kB/s |  98 kB     00:00    
    (49/69): perl-Term-ANSIColor-4.06-396.el8.noarch.r 502 kB/s |  46 kB     00:00    
    (50/69): perl-Term-Cap-1.17-395.el8.noarch.rpm     349 kB/s |  23 kB     00:00    
    (51/69): perl-Text-ParseWords-3.30-395.el8.noarch. 327 kB/s |  18 kB     00:00    
    (52/69): perl-Text-Tabs+Wrap-2013.0523-395.el8.noa 334 kB/s |  24 kB     00:00    
    (53/69): perl-Time-Local-1.280-1.el8.noarch.rpm    424 kB/s |  34 kB     00:00    
    (54/69): perl-Encode-2.97-3.el8.x86_64.rpm         1.1 MB/s | 1.5 MB     00:01    
    (55/69): perl-constant-1.33-396.el8.noarch.rpm     402 kB/s |  25 kB     00:00    
    (56/69): perl-Unicode-Normalize-1.25-396.el8.x86_6 889 kB/s |  82 kB     00:00    
    (57/69): perl-macros-5.26.3-416.el8.x86_64.rpm     539 kB/s |  72 kB     00:00    
    (58/69): perl-parent-0.237-1.el8.noarch.rpm        280 kB/s |  20 kB     00:00    
    (59/69): perl-podlators-4.11-1.el8.noarch.rpm      609 kB/s | 118 kB     00:00    
    (60/69): perl-threads-2.21-2.el8.x86_64.rpm        506 kB/s |  61 kB     00:00    
    (61/69): perl-threads-shared-1.58-2.el8.x86_64.rpm 468 kB/s |  48 kB     00:00    
    (62/69): policycoreutils-python-utils-2.9-9.el8.no 694 kB/s | 251 kB     00:00    
    (63/69): python3-audit-3.0-0.17.20191104git1c2f876 572 kB/s |  86 kB     00:00    
    (64/69): python3-libsemanage-2.9-2.el8.x86_64.rpm  615 kB/s | 127 kB     00:00    
    (65/69): perl-libs-5.26.3-416.el8.x86_64.rpm       839 kB/s | 1.6 MB     00:01    
    (66/69): python3-setools-4.2.2-2.el8.x86_64.rpm    691 kB/s | 601 kB     00:00    
    (67/69): zlib-devel-1.2.11-13.el8.x86_64.rpm       473 kB/s |  57 kB     00:00    
    (68/69): python3-policycoreutils-2.9-9.el8.noarch. 934 kB/s | 2.2 MB     00:02    
    (69/69): perl-interpreter-5.26.3-416.el8.x86_64.rp 1.2 MB/s | 6.3 MB     00:05    
    -----------------------------------------------------------------------------------
    Total                                              4.0 MB/s |  55 MB     00:13     
    warning: /var/cache/dnf/AppStream-a520ed22b0a8a736/packages/mariadb-connector-c-config-3.0.7-1.el8.noarch.rpm: Header V3 RSA/SHA256 Signature, key ID 8483c65d: NOKEY
    CentOS-8 - AppStream                               961 kB/s | 1.6 kB     00:00    
    Importing GPG key 0x8483C65D:
     Userid     : "CentOS (CentOS Official Signing Key) <security@centos.org>"
     Fingerprint: 99DB 70FA E1D7 CE22 7FB6 4882 05B5 55B3 8483 C65D
     From       : /etc/pki/rpm-gpg/RPM-GPG-KEY-centosofficial
    Key imported successfully
    Running transaction check
    Transaction check succeeded.
    Running transaction test
    Transaction test succeeded.
    Running transaction
      Preparing        :                                                           1/1 
      Installing       : perl-Exporter-5.72-396.el8.noarch                        1/69 
      Installing       : perl-libs-4:5.26.3-416.el8.x86_64                        2/69 
      Installing       : perl-Carp-1.42-396.el8.noarch                            3/69 
      Installing       : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64               4/69 
      Installing       : perl-parent-1:0.237-1.el8.noarch                         5/69 
      Installing       : perl-Text-ParseWords-3.30-395.el8.noarch                 6/69 
      Installing       : zlib-devel-1.2.11-13.el8.x86_64                          7/69 
      Installing       : mariadb-connector-c-config-3.0.7-1.el8.noarch            8/69 
      Installing       : mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86    9/69 
      Installing       : mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64       10/69 
      Installing       : mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86   11/69 
      Installing       : mysql-libs-8.0.17-3.module_el8.0.0+181+899d6349.x86_6   12/69 
      Installing       : perl-Term-ANSIColor-4.06-396.el8.noarch                 13/69 
      Installing       : perl-macros-4:5.26.3-416.el8.x86_64                     14/69 
      Installing       : perl-Errno-1.28-416.el8.x86_64                          15/69 
      Installing       : perl-Socket-4:2.027-3.el8.x86_64                        16/69 
      Installing       : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch            17/69 
      Installing       : perl-Unicode-Normalize-1.25-396.el8.x86_64              18/69 
      Installing       : perl-File-Path-2.15-2.el8.noarch                        19/69 
      Installing       : perl-IO-1.38-416.el8.x86_64                             20/69 
      Installing       : perl-PathTools-3.74-1.el8.x86_64                        21/69 
      Installing       : perl-constant-1.33-396.el8.noarch                       22/69 
      Installing       : perl-threads-1:2.21-2.el8.x86_64                        23/69 
      Installing       : perl-threads-shared-1.58-2.el8.x86_64                   24/69 
      Installing       : perl-interpreter-4:5.26.3-416.el8.x86_64                25/69 
      Installing       : perl-MIME-Base64-3.15-396.el8.x86_64                    26/69 
      Installing       : perl-IO-Socket-IP-0.39-5.el8.noarch                     27/69 
      Installing       : perl-Time-Local-1:1.280-1.el8.noarch                    28/69 
      Installing       : perl-Digest-1.17-395.el8.noarch                         29/69 
      Installing       : perl-Digest-MD5-2.55-396.el8.x86_64                     30/69 
      Installing       : perl-Net-SSLeay-1.88-1.el8.x86_64                       31/69 
      Installing       : perl-Data-Dumper-2.167-399.el8.x86_64                   32/69 
      Installing       : perl-File-Temp-0.230.600-1.el8.noarch                   33/69 
      Installing       : perl-Pod-Escapes-1:1.07-395.el8.noarch                  34/69 
      Installing       : perl-Storable-1:3.11-3.el8.x86_64                       35/69 
      Installing       : perl-Term-Cap-1.17-395.el8.noarch                       36/69 
      Installing       : perl-Mozilla-CA-20160104-7.el8.noarch                   37/69 
      Installing       : perl-Encode-4:2.97-3.el8.x86_64                         38/69 
      Installing       : perl-Pod-Simple-1:3.35-395.el8.noarch                   39/69 
      Installing       : perl-Getopt-Long-1:2.50-4.el8.noarch                    40/69 
      Installing       : perl-podlators-4.11-1.el8.noarch                        41/69 
      Installing       : perl-Pod-Usage-4:1.69-395.el8.noarch                    42/69 
      Installing       : perl-Pod-Perldoc-3.28-396.el8.noarch                    43/69 
      Installing       : perl-HTTP-Tiny-0.074-1.el8.noarch                       44/69 
      Installing       : perl-IO-Socket-SSL-2.066-4.el8.noarch                   45/69 
      Installing       : perl-libnet-3.11-3.el8.noarch                           46/69 
      Installing       : perl-URI-1.73-3.el8.noarch                              47/69 
      Installing       : python3-setools-4.2.2-2.el8.x86_64                      48/69 
      Installing       : python3-libsemanage-2.9-2.el8.x86_64                    49/69 
      Installing       : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64    50/69 
      Installing       : pcre2-utf32-10.32-1.el8.x86_64                          51/69 
      Installing       : pcre2-utf16-10.32-1.el8.x86_64                          52/69 
      Installing       : pcre2-devel-10.32-1.el8.x86_64                          53/69 
      Installing       : libverto-devel-0.3.0-5.el8.x86_64                       54/69 
      Installing       : libsepol-devel-2.9-1.el8.x86_64                         55/69 
      Installing       : libselinux-devel-2.9-3.el8.x86_64                       56/69 
      Installing       : libkadm5-1.17-18.el8.x86_64                             57/69 
      Installing       : libevent-2.1.8-5.el8.x86_64                             58/69 
      Installing       : libcom_err-devel-1.45.4-3.el8.x86_64                    59/69 
      Installing       : keyutils-libs-devel-1.5.10-6.el8.x86_64                 60/69 
      Installing       : krb5-devel-1.17-18.el8.x86_64                           61/69 
      Installing       : openssl-devel-1:1.1.1c-15.el8.x86_64                    62/69 
      Installing       : checkpolicy-2.9-1.el8.x86_64                            63/69 
      Installing       : python3-policycoreutils-2.9-9.el8.noarch                64/69 
      Installing       : policycoreutils-python-utils-2.9-9.el8.noarch           65/69 
      Installing       : protobuf-lite-3.5.0-7.el8.x86_64                        66/69 
      Installing       : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64       67/69 
      Running scriptlet: mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64       67/69 
      Running scriptlet: mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86   68/69 
      Installing       : mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86   68/69 
      Running scriptlet: mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86   68/69 
    ValueError: File context for /var/log/mysql(/.*)? already defined
    
      Installing       : mysql-devel-8.0.17-3.module_el8.0.0+181+899d6349.x86_   69/69 
      Running scriptlet: mysql-devel-8.0.17-3.module_el8.0.0+181+899d6349.x86_   69/69 
      Verifying        : mariadb-connector-c-config-3.0.7-1.el8.noarch            1/69 
      Verifying        : mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64        2/69 
      Verifying        : mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64        3/69 
      Verifying        : mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86    4/69 
      Verifying        : mysql-devel-8.0.17-3.module_el8.0.0+181+899d6349.x86_    5/69 
      Verifying        : mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86    6/69 
      Verifying        : mysql-libs-8.0.17-3.module_el8.0.0+181+899d6349.x86_6    7/69 
      Verifying        : mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86    8/69 
      Verifying        : perl-Digest-1.17-395.el8.noarch                          9/69 
      Verifying        : perl-Digest-MD5-2.55-396.el8.x86_64                     10/69 
      Verifying        : perl-IO-Socket-IP-0.39-5.el8.noarch                     11/69 
      Verifying        : perl-IO-Socket-SSL-2.066-4.el8.noarch                   12/69 
      Verifying        : perl-Mozilla-CA-20160104-7.el8.noarch                   13/69 
      Verifying        : perl-Net-SSLeay-1.88-1.el8.x86_64                       14/69 
      Verifying        : perl-URI-1.73-3.el8.noarch                              15/69 
      Verifying        : perl-libnet-3.11-3.el8.noarch                           16/69 
      Verifying        : protobuf-lite-3.5.0-7.el8.x86_64                        17/69 
      Verifying        : checkpolicy-2.9-1.el8.x86_64                            18/69 
      Verifying        : keyutils-libs-devel-1.5.10-6.el8.x86_64                 19/69 
      Verifying        : krb5-devel-1.17-18.el8.x86_64                           20/69 
      Verifying        : libcom_err-devel-1.45.4-3.el8.x86_64                    21/69 
      Verifying        : libevent-2.1.8-5.el8.x86_64                             22/69 
      Verifying        : libkadm5-1.17-18.el8.x86_64                             23/69 
      Verifying        : libselinux-devel-2.9-3.el8.x86_64                       24/69 
      Verifying        : libsepol-devel-2.9-1.el8.x86_64                         25/69 
      Verifying        : libverto-devel-0.3.0-5.el8.x86_64                       26/69 
      Verifying        : openssl-devel-1:1.1.1c-15.el8.x86_64                    27/69 
      Verifying        : pcre2-devel-10.32-1.el8.x86_64                          28/69 
      Verifying        : pcre2-utf16-10.32-1.el8.x86_64                          29/69 
      Verifying        : pcre2-utf32-10.32-1.el8.x86_64                          30/69 
      Verifying        : perl-Carp-1.42-396.el8.noarch                           31/69 
      Verifying        : perl-Data-Dumper-2.167-399.el8.x86_64                   32/69 
      Verifying        : perl-Encode-4:2.97-3.el8.x86_64                         33/69 
      Verifying        : perl-Errno-1.28-416.el8.x86_64                          34/69 
      Verifying        : perl-Exporter-5.72-396.el8.noarch                       35/69 
      Verifying        : perl-File-Path-2.15-2.el8.noarch                        36/69 
      Verifying        : perl-File-Temp-0.230.600-1.el8.noarch                   37/69 
      Verifying        : perl-Getopt-Long-1:2.50-4.el8.noarch                    38/69 
      Verifying        : perl-HTTP-Tiny-0.074-1.el8.noarch                       39/69 
      Verifying        : perl-IO-1.38-416.el8.x86_64                             40/69 
      Verifying        : perl-MIME-Base64-3.15-396.el8.x86_64                    41/69 
      Verifying        : perl-PathTools-3.74-1.el8.x86_64                        42/69 
      Verifying        : perl-Pod-Escapes-1:1.07-395.el8.noarch                  43/69 
      Verifying        : perl-Pod-Perldoc-3.28-396.el8.noarch                    44/69 
      Verifying        : perl-Pod-Simple-1:3.35-395.el8.noarch                   45/69 
      Verifying        : perl-Pod-Usage-4:1.69-395.el8.noarch                    46/69 
      Verifying        : perl-Scalar-List-Utils-3:1.49-2.el8.x86_64              47/69 
      Verifying        : perl-Socket-4:2.027-3.el8.x86_64                        48/69 
      Verifying        : perl-Storable-1:3.11-3.el8.x86_64                       49/69 
      Verifying        : perl-Term-ANSIColor-4.06-396.el8.noarch                 50/69 
      Verifying        : perl-Term-Cap-1.17-395.el8.noarch                       51/69 
      Verifying        : perl-Text-ParseWords-3.30-395.el8.noarch                52/69 
      Verifying        : perl-Text-Tabs+Wrap-2013.0523-395.el8.noarch            53/69 
      Verifying        : perl-Time-Local-1:1.280-1.el8.noarch                    54/69 
      Verifying        : perl-Unicode-Normalize-1.25-396.el8.x86_64              55/69 
      Verifying        : perl-constant-1.33-396.el8.noarch                       56/69 
      Verifying        : perl-interpreter-4:5.26.3-416.el8.x86_64                57/69 
      Verifying        : perl-libs-4:5.26.3-416.el8.x86_64                       58/69 
      Verifying        : perl-macros-4:5.26.3-416.el8.x86_64                     59/69 
      Verifying        : perl-parent-1:0.237-1.el8.noarch                        60/69 
      Verifying        : perl-podlators-4.11-1.el8.noarch                        61/69 
      Verifying        : perl-threads-1:2.21-2.el8.x86_64                        62/69 
      Verifying        : perl-threads-shared-1.58-2.el8.x86_64                   63/69 
      Verifying        : policycoreutils-python-utils-2.9-9.el8.noarch           64/69 
      Verifying        : python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64    65/69 
      Verifying        : python3-libsemanage-2.9-2.el8.x86_64                    66/69 
      Verifying        : python3-policycoreutils-2.9-9.el8.noarch                67/69 
      Verifying        : python3-setools-4.2.2-2.el8.x86_64                      68/69 
      Verifying        : zlib-devel-1.2.11-13.el8.x86_64                         69/69 
    
    Installed:
      checkpolicy-2.9-1.el8.x86_64                                                     
      keyutils-libs-devel-1.5.10-6.el8.x86_64                                          
      krb5-devel-1.17-18.el8.x86_64                                                    
      libcom_err-devel-1.45.4-3.el8.x86_64                                             
      libevent-2.1.8-5.el8.x86_64                                                      
      libkadm5-1.17-18.el8.x86_64                                                      
      libselinux-devel-2.9-3.el8.x86_64                                                
      libsepol-devel-2.9-1.el8.x86_64                                                  
      libverto-devel-0.3.0-5.el8.x86_64                                                
      mariadb-connector-c-config-3.0.7-1.el8.noarch                                    
      mecab-0.996-1.module_el8.0.0+41+ca30bab6.9.x86_64                                
      mysql-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                                
      mysql-common-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                         
      mysql-devel-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                          
      mysql-errmsg-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                         
      mysql-libs-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                           
      mysql-server-8.0.17-3.module_el8.0.0+181+899d6349.x86_64                         
      openssl-devel-1:1.1.1c-15.el8.x86_64                                             
      pcre2-devel-10.32-1.el8.x86_64                                                   
      pcre2-utf16-10.32-1.el8.x86_64                                                   
      pcre2-utf32-10.32-1.el8.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-416.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-416.el8.x86_64                                                      
      perl-IO-Socket-IP-0.39-5.el8.noarch                                              
      perl-IO-Socket-SSL-2.066-4.el8.noarch                                            
      perl-MIME-Base64-3.15-396.el8.x86_64                                             
      perl-Mozilla-CA-20160104-7.el8.noarch                                            
      perl-Net-SSLeay-1.88-1.el8.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-416.el8.x86_64                                         
      perl-libnet-3.11-3.el8.noarch                                                    
      perl-libs-4:5.26.3-416.el8.x86_64                                                
      perl-macros-4:5.26.3-416.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-9.el8.noarch                                    
      protobuf-lite-3.5.0-7.el8.x86_64                                                 
      python3-audit-3.0-0.17.20191104git1c2f876.el8.x86_64                             
      python3-libsemanage-2.9-2.el8.x86_64                                             
      python3-policycoreutils-2.9-9.el8.noarch                                         
      python3-setools-4.2.2-2.el8.x86_64                                               
      zlib-devel-1.2.11-13.el8.x86_64                                                  
    
    Complete!
    [root@localhost ~]# mysqld --install --user=root
    [root@localhost ~]# mysqld --initialize --user=mysql
    [root@localhost ~]# mysqld --initialize --lower-case-table-names=1
    [root@localhost ~]# cat /var/log/mysql/mysqld.log
    2020-09-01T08:03:16.286242Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.17) starting as process 8036
    2020-09-01T08:03:16.300375Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
    2020-09-01T08:03:16.300446Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
    2020-09-01T08:03:16.300498Z 0 [ERROR] [MY-010119] [Server] Aborting
    2020-09-01T08:03:16.300755Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.17)  Source distribution.
    2020-09-01T08:03:25.523538Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.17) initializing of server in progress as process 22923
    2020-09-01T08:03:25.524591Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
    2020-09-01T08:03:25.524614Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
    2020-09-01T08:03:25.524676Z 0 [ERROR] [MY-010119] [Server] Aborting
    2020-09-01T08:03:25.524752Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.17)  Source distribution.
    2020-09-01T08:03:35.984050Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.17) initializing of server in progress as process 28279
    2020-09-01T08:03:35.985204Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
    2020-09-01T08:03:35.985285Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
    2020-09-01T08:03:35.985321Z 0 [ERROR] [MY-010119] [Server] Aborting
    2020-09-01T08:03:35.985395Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.17)  Source distribution.
    [root@localhost ~]# rm -rf /var/lib/mysql
    [root@localhost ~]# mysqld --initialize --console
    [root@localhost ~]# chown -R mysql:mysql /var/lib/mysql/
    [root@localhost ~]# systemctl start mysqld
    [root@localhost ~]# systemctl status mysqld
    ● mysqld.service - MySQL 8.0 database server
       Loaded: loaded (/usr/lib/systemd/system/mysqld.service; disabled; vendor preset>
       Active: active (running) since Tue 2020-09-01 16:04:21 CST; 5s ago
      Process: 28436 ExecStartPost=/usr/libexec/mysql-check-upgrade (code=exited, stat>
      Process: 28356 ExecStartPre=/usr/libexec/mysql-prepare-db-dir mysqld.service (co>
      Process: 28332 ExecStartPre=/usr/libexec/mysql-check-socket (code=exited, status>
     Main PID: 28393 (mysqld)
       Status: "Server is operational"
        Tasks: 39 (limit: 11302)
       Memory: 382.4M
       CGroup: /system.slice/mysqld.service
               └─28393 /usr/libexec/mysqld --basedir=/usr
    
    Sep 01 16:04:18 localhost.localdomain systemd[1]: Starting MySQL 8.0 database serv>
    Sep 01 16:04:21 localhost.localdomain mysql-check-upgrade[28436]: The datadir loca>
    Sep 01 16:04:21 localhost.localdomain mysql-check-upgrade[28436]:   1. Back-up you>
    Sep 01 16:04:21 localhost.localdomain mysql-check-upgrade[28436]:   2. Start the d>
    Sep 01 16:04:21 localhost.localdomain mysql-check-upgrade[28436]:   3. Run 'mysql_>
    Sep 01 16:04:21 localhost.localdomain mysql-check-upgrade[28436]: Read more about >
    Sep 01 16:04:21 localhost.localdomain mysql-check-upgrade[28436]: http://dev.mysql>
    Sep 01 16:04:21 localhost.localdomain systemd[1]: Started MySQL 8.0 database serve>
    
    [root@localhost ~]# ^C
    [root@localhost ~]# cat /var/log/mysql/mysqld.log
    2020-09-01T08:03:16.286242Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.17) starting as process 8036
    2020-09-01T08:03:16.300375Z 1 [ERROR] [MY-011011] [Server] Failed to find valid data directory.
    2020-09-01T08:03:16.300446Z 0 [ERROR] [MY-010020] [Server] Data Dictionary initialization failed.
    2020-09-01T08:03:16.300498Z 0 [ERROR] [MY-010119] [Server] Aborting
    2020-09-01T08:03:16.300755Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.17)  Source distribution.
    2020-09-01T08:03:25.523538Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.17) initializing of server in progress as process 22923
    2020-09-01T08:03:25.524591Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
    2020-09-01T08:03:25.524614Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
    2020-09-01T08:03:25.524676Z 0 [ERROR] [MY-010119] [Server] Aborting
    2020-09-01T08:03:25.524752Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.17)  Source distribution.
    2020-09-01T08:03:35.984050Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.17) initializing of server in progress as process 28279
    2020-09-01T08:03:35.985204Z 0 [ERROR] [MY-010457] [Server] --initialize specified but the data directory has files in it. Aborting.
    2020-09-01T08:03:35.985285Z 0 [ERROR] [MY-013236] [Server] The designated data directory /var/lib/mysql/ is unusable. You can remove all files that the server added to it.
    2020-09-01T08:03:35.985321Z 0 [ERROR] [MY-010119] [Server] Aborting
    2020-09-01T08:03:35.985395Z 0 [System] [MY-010910] [Server] /usr/libexec/mysqld: Shutdown complete (mysqld 8.0.17)  Source distribution.
    2020-09-01T08:04:00.208778Z 0 [System] [MY-013169] [Server] /usr/libexec/mysqld (mysqld 8.0.17) initializing of server in progress as process 28282
    2020-09-01T08:04:02.022251Z 5 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: u;*pHkkhe13T
    2020-09-01T08:04:02.704903Z 0 [System] [MY-013170] [Server] /usr/libexec/mysqld (mysqld 8.0.17) initializing of server has completed
    2020-09-01T08:04:19.678034Z 0 [System] [MY-010116] [Server] /usr/libexec/mysqld (mysqld 8.0.17) starting as process 28393
    2020-09-01T08:04:21.444889Z 0 [Warning] [MY-010068] [Server] CA certificate ca.pem is self signed.
    2020-09-01T08:04:21.463100Z 0 [System] [MY-010931] [Server] /usr/libexec/mysqld: ready for connections. Version: '8.0.17'  socket: '/var/lib/mysql/mysql.sock'  port: 3306  Source distribution.
    2020-09-01T08:04:21.531457Z 0 [System] [MY-011323] [Server] X Plugin ready for connections. Socket: '/var/lib/mysql/mysqlx.sock' bind-address: '::' port: 33060
    [root@localhost ~]# mysql -u root -p
    Enter password: 
    Welcome to the MySQL monitor.  Commands end with ; or g.
    Your MySQL connection id is 8
    Server version: 8.0.17
    
    Copyright (c) 2000, 2019, Oracle and/or its affiliates. All rights reserved.
    
    Oracle is a registered trademark of Oracle Corporation and/or its
    affiliates. Other names may be trademarks of their respective
    owners.
    
    Type 'help;' or 'h' for help. Type 'c' to clear the current input statement.
    
    mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'test@123';
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> use mysql
    Reading table information for completion of table and column names
    You can turn off this feature to get a quicker startup with -A
    
    Database changed
    mysql> select Host,User from user;
    +-----------+------------------+
    | Host      | User             |
    +-----------+------------------+
    | localhost | mysql.infoschema |
    | localhost | mysql.session    |
    | localhost | mysql.sys        |
    | localhost | root             |
    +-----------+------------------+
    4 rows in set (0.00 sec)
    
    mysql> update user set host = '%' where user ='root';
    Query OK, 1 row affected (0.00 sec)
    Rows matched: 1  Changed: 1  Warnings: 0
    
    mysql> flush privileges;
    Query OK, 0 rows affected (0.01 sec)
    
    mysql> exit
    Bye
    [root@localhost ~]# 
  • 相关阅读:
    Ubuntu 忘记root密码的解决方法
    zabbix 参数说明
    Python 进阶_OOP 面向对象编程_self 的实例绑定
    centos 6.5关闭NetworkManager
    本地yum源
    VMware通过VMnet8共享本地网络
    EasyUI之手风琴Accordion
    php 分页
    修改css
    /Home/Tpl/Equipment/rangeIndex.html 里调用魔板
  • 原文地址:https://www.cnblogs.com/wangpengzong/p/13596927.html
Copyright © 2011-2022 走看看