• CentOS7用yum安装MySQL8.0 2209170054


    CentOS7用yum安装MySQL8.0 2209170054

    Ubuntu20.04安装MySQL很轻松, apt install mysql-server就搞定了
    CentOS7安装MySQL很麻烦, 不能用yum直接安装, 要下载mysql官方的安装包或yum仓库配置,
    apt安装的mysql不带validate_password组件
    yum安装的mysql带validate_password组件,密码强度要求变态,注意可能以括号开头,是密码的一部分



    文章目录

    MySQL的官方下载, 不但有安装包, 还有yum仓库配置包可选

    本次不使用安装包安装, 而是yum配置包配置yum后,用yum安装

    点击打开YUM仓库安装MySQL的yum配置文件的下载地址—https://dev.mysql.com/downloads/repo/yum/

    在这里插入图片描述

    2018年06月, 下载到的是mysql80-community-release-el7-1.noarch.rpm 安装的是MySQL8.0.11
    2018年12月, 下载到的是 mysql80-community-release-el7-1.noarch.rpm 安装的是MySQL8.0.13
    2022年09月, 下载到的是 mysql80-community-release-el7-7.noarch.rpm 安装的是MySQL8.0.30

    发文时,红框的链接为:https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm , 可以下载到 mysql80-community-release-el7-7.noarch.rpm 文件, 将会安装MySQL8.0.30版本

    https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    
    • 1

    第一步,下载并使用mysql80-community-release-el7-7.noarch.rpm 配置yum

    可以直接用yum下载并安装这个文件
    sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    
    • 1
    也可以分步
    1. sudo yum install wget , 下载wget
    2. sudo wget -O https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm , 用wget来下载这个文件
    3. sudo rpm -ivh mysql80-community-release-el7-7.noarch.rpm , 用rpm安装这个文件
      或者
      sudo yum install mysql80-community-release-el7-7.noarch.rpm , 用yum安装这个文件
      rpm安装的话,可以在wget下载时重命名,比如改名为 temp , 少打字
      yum安装的话,不能去掉.rpm结尾的扩展名

    第二步, 此时就能用yum安装新版MySQL了

    sudo yum install -y mysql-server
    
    • 1

    或者

    sudo yum install -y mysql-community-server.x86_64
    
    • 1

    效果一样



    第三步, 启动mysqld服务

    CentOS的mysql服务是mysqld , Ubuntu是mysql

    • 启动CentOS7的MySQL8.0用的是 systemctl start mysqld
    • 启动Ubuntu20.04的MySQL8.0用的是 systemctl start mysql
    sudo systemctl enable mysqld
    sudo systemctl start mysqld
    
    • 1
    • 2

    Ubuntu : systemctl enable mysql ; systemctl start mysql
    CentOS: systemctl enable mysqld ; systemctl start mysqld


    第四步, 查看生成的root变态密码, 用变态密码登录

    Ubuntu20.04 下用apt安装的mysql8.0.30默认不带validate_password组件,可以使用空密码
    CentOS7下用yum安装的mysql8.0.30带validate_password组件,默认要大小写字母数字特殊符号一起用,还有长度要求,体验很差
    密码可能以括号开头结尾

    查看生成的初始变态密码 grep 'temporary password' /var/log/mysqld.log;
    grep 'temporary password' /var/log/mysqld.log;
    
    • 1

    例如

    [root@VboxC7min2207 ~]# grep 'temporary password' /var/log/mysqld.log;
    2022-09-16T19:14:48.584198Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: iB9tnxeshg>a
    
    • 1
    • 2

    看到自动生成的初始变态密码是 : iB9tnxeshg>a
    或者

    awk -F': ' '/A temporary password is generated for/{print $2}' /var/log/mysqld.log
    
    • 1
    [root@VboxC7min2207 ~]# awk -F': ' '/A temporary password is generated for/{print $2}' /var/log/mysqld.log
    )Bkisp%38gfy
    
    • 1
    • 2

    看到自动生成的初始变态密码是 : )Bkisp%38gfy

    用初始密码登录

    手动输入密码

    mysql -uroot -p
    
    • 1

    或者复制粘贴密码
    用复制粘贴的话,因为有特殊字符,所以要加上单引号和双引号
    并且-p单双引号之间不能有空格

    mysql -uroot -p')Bkisp%38gfy'
    
    • 1

    不加单或双引号复制粘贴的结果👇

    [root@VboxC7min2207 ~]# grep 'temporary password' /var/log/mysqld.log;
    2022-09-16T19:14:48.584198Z 6 [Note] [MY-010454] [Server] A temporary password is generated for root@localhost: iB9tnxeshg>a
    [root@VboxC7min2207 ~]# mysql -uroot -piB9tnxeshg>a
    mysql: [Warning] Using a password on the command line interface can be insecure.
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
    [root@VboxC7min2207 ~]# mysql -uroot -p iB9tnxeshg>a
    Enter password:
    ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8

    第五步, 登录后,必须修改密码才能执行其它操作

    必须先更改为另一个变态密码, 可以不用记住它, 设好后, 降低密码强度, 或者卸载validate_password这个变态组件
    设置密码方法1

    ALTER USER root@localhost IDENTIFIED BY 'ABCDEFGhijklmn1234567!!!';
    
    • 1

    设置密码方法2

    SET PASSWORD='ABCDEFGhijklmn1234567!!!';
    
    • 1

    第六步,修改初始密码后, 可以设置降低密码强度, 使用简单密码

    降低密码强度要求的方法有

    1. 设置validate_password的相关选项
    2. 卸载validate_password
    可选:降低 validate_password 组件对密码强度的要求
    • SET GLOBAL validate_password.policy=LOW; 降低密码复杂度要求
    • SET GLOBAL validate_password.mixed_case_count=0; 最少大小写字符数
    • SET GLOBAL validate_password.number_count=0; 最少数字字符数
    • SET GLOBAL validate_password.special_char_count=0; 最少特殊字符数
    • SET GLOBAL validate_password.check_user_name=OFF; 允许用户名和密码相同
    • SET GLOBAL validate_password.length=0; 设置密码最小长度, 要放到最后设置, 否则可能被其它值影响, 使其没法为0, 可能是4或者2
    ### 密码策略: 0或LOW是只检查长度  ,  1或MEDIUM是检查长度数字字母特殊字符的个数  ,  2或STRONG是比1多检查字典文件 ;
    SET GLOBAL validate_password.policy=LOW;
    ### 最少大小写字符数
    SET GLOBAL validate_password.mixed_case_count=0;
    ### 最少数字字符数
    SET GLOBAL validate_password.number_count=0;
    ### 最少特殊字符数
    SET GLOBAL validate_password.special_char_count=0;
    ### 是否允许密码包含正反用户名 , 取值ON/OFF
    SET GLOBAL validate_password.check_user_name=OFF;
    ### 密码最小长度, 要放到最后设置,  否则可能被其它值影响, 使其没法为0, 可能是4或者2
    SET GLOBAL validate_password.length=0;
    ### 查看 validate_password 的相关MySQL系统变量
    SHOW VARIABLES LIKE '%validate_password%';
    
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    可选: 卸载 validate_password 组件
    • 安装 validate_password 组件
      INSTALL COMPONENT 'file://component_validate_password';

    • 卸载 validate_password 卸载
      UNINSTALL COMPONENT 'file://component_validate_password';

    我选卸载 validate_password 插件

    UNINSTALL COMPONENT 'file://component_validate_password';
    
    • 1

    然后就能设为空密码😄

    ALTER USER root@localhost IDENTIFIED BY '';
    
    • 1

    SET PASSWORD='';
    
    • 1

    操作系统的root输入mysql就能直接登录




    第七步, 创建远程用户,开放防火墙端口3306

    创建远程用户

    创建一个名为remote的远程用户, remote等效’remote’@‘%’

    ###  创建一个名为remote的远程用户, remote等效'remote'@'%'
    CREATE USER remote IDENTIFIED BY '';
    
    • 1
    • 2

    创建一个可以用 Navicat11 登录的远程用户

    ###   创建一个名为remote的远程用户, remote等效'remote'@'%', 使用mysql5.7旧版密码插件,方便使用Navicat11等登录
    CREATE USER remote IDENTIFIED WITH mysql_native_password BY '';
    
    • 1
    • 2

    赋予remote所有权限和权力传递的权限,并将root角色授予remote

    GRANT ALL ON *.* TO 'remote'@'%' WITH GRANT OPTION; GRANT root@'localhost' TO remote; SET DEFAULT ROLE root@'localhost' TO remote; FLUSH PRIVILEGES;
    
    
    • 1
    • 2
    开放 firewalld 防火墙的3306端口
    sudo firewall-cmd --zone=public --permanent --add-port=3306/tcp ; sudo systemctl restart firewalld ;
    
    
    • 1
    • 2

    用脚本安装

    CentOS7一步安装MySQL8.0并且第一次登录
    #!/bin/bash
    ### CentOS7一步安装MySQL8.0并且第一次登录
    sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    sudo yum install -y mysql-community-server.x86_64
    sudo systemctl enable mysqld
    sudo systemctl start mysqld
    MysqlInitialTemporaryPassword=`awk -F': ' '/A temporary password is generated for/{print $2}' /var/log/mysqld.log`
    MysqlFirstLoginCodeCommand="mysql -uroot -p"$MysqlInitialTemporaryPassword
    echo $MysqlFirstLoginCodeCommand;$MysqlFirstLoginCodeCommand
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    CentOS7一步安装MySQL8.0并且将root@localhost免密
    #!/bin/bash
    ### CentOS7一步安装MySQL8.0并且将root@localhost免密
    sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    sudo yum install -y mysql-community-server.x86_64
    sudo systemctl enable mysqld
    sudo systemctl start mysqld
    MysqlInitialTemporaryPassword=`awk -F': ' '/A temporary password is generated for/{print $2}' /var/log/mysqld.log`
    MysqlFirstLoginCodeCommand="mysql -uroot -p"$MysqlInitialTemporaryPassword
    echo $MysqlFirstLoginCodeCommand;$MysqlFirstLoginCodeCommand
    ALTER USER root@localhost IDENTIFIED BY 'ABCDEFGhijklmn1234567!!!';
    ### 密码策略: 0或LOW是只检查长度  ,  1或MEDIUM是检查长度数字字母特殊字符的个数  ,  2或STRONG是比1多检查字典文件 ;
    SET GLOBAL validate_password.policy=LOW;
    ### 最少大小写字符数
    SET GLOBAL validate_password.mixed_case_count=0;
    ### 最少数字字符数
    SET GLOBAL validate_password.number_count=0;
    ### 最少特殊字符数
    SET GLOBAL validate_password.special_char_count=0;
    ### 是否允许密码包含正反用户名 , 取值ON/OFF
    SET GLOBAL validate_password.check_user_name=OFF;
    ### 密码最小长度, 要放到最后设置,  否则可能被其它值影响, 使其没法为0, 可能是4或者2
    SET GLOBAL validate_password.length=0;
    ### 查看 validate_password 的相关MySQL系统变量
    SHOW VARIABLES LIKE '%validate_password%';
    SET PASSWORD='';
    exit
    mysql -uroot
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    CentOS7一步安装MySQL8.0并且将root@localhost免密, 创建免密的remote用户, 开放3306端口
    #!/bin/bash
    ### CentOS7一步安装MySQL8.0并且将root@localhost免密, 创建免密的remote用户, 开放3306端口
    sudo -s
    sudo yum remove -y mariadb;
    sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    sudo yum install -y mysql-community-server.x86_64
    sudo systemctl enable mysqld
    sudo systemctl start mysqld
    MysqlInitialTemporaryPassword=`sudo awk -F': ' '/A temporary password is generated for/{print $2}' /var/log/mysqld.log`
    MysqlFirstLoginCodeCommand="mysql -uroot -p"$MysqlInitialTemporaryPassword
    echo $MysqlFirstLoginCodeCommand;$MysqlFirstLoginCodeCommand
    ALTER USER root@localhost IDENTIFIED BY 'ABCDEFGhijklmn1234567!!!';
    ### 密码策略: 0或LOW是只检查长度  ,  1或MEDIUM是检查长度数字字母特殊字符的个数  ,  2或STRONG是比1多检查字典文件 ;
    SET GLOBAL validate_password.policy=LOW;
    ### 最少大小写字符数
    SET GLOBAL validate_password.mixed_case_count=0;
    ### 最少数字字符数
    SET GLOBAL validate_password.number_count=0;
    ### 最少特殊字符数
    SET GLOBAL validate_password.special_char_count=0;
    ### 是否允许密码包含正反用户名 , 取值ON/OFF
    SET GLOBAL validate_password.check_user_name=OFF;
    ### 密码最小长度, 要放到最后设置,  否则可能被其它值影响, 使其没法为0, 可能是4或者2
    SET GLOBAL validate_password.length=0;
    ### 查看 validate_password 的相关MySQL系统变量
    SHOW VARIABLES LIKE '%validate_password%';
    SET PASSWORD='';
    CREATE USER IF NOT EXISTS remote IDENTIFIED WITH mysql_native_password BY ''; 
    GRANT ALL ON *.* TO 'remote'@'%' WITH GRANT OPTION; GRANT root@'localhost' TO remote; SET DEFAULT ROLE root@'localhost' TO remote; FLUSH PRIVILEGES;
    exit
    sudo firewall-cmd --zone=public --permanent --add-port=3306/tcp ; sudo systemctl restart firewalld ;
    mysql -uremote
    
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33




    题外

    对比 , 在执行sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm前, 和执行后, yum list mysql*的变化

    yum list mysql*
    
    sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    
    yum list mysql*
    
    • 1
    • 2
    • 3
    • 4
    • 5

    可见, 在执行sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm前,
    可安装的软件包只有

    MySQL-python.x86_64 1.2.5-1.el7 base
    mysql-connector-java.noarch 1:5.1.25-3.el7 base
    mysql-connector-odbc.x86_64 5.2.5-8.el7 base

    执行sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    可安装的软件包有

    MySQL-python.x86_64 1.2.5-1.el7 base
    mysql-community-client.i686 8.0.30-1.el7 mysql80-community
    mysql-community-client.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-client-plugins.i686 8.0.30-1.el7 mysql80-community
    mysql-community-client-plugins.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-common.i686 8.0.30-1.el7 mysql80-community
    mysql-community-common.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-devel.i686 8.0.30-1.el7 mysql80-community
    mysql-community-devel.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-embedded-compat.i686 8.0.30-1.el7 mysql80-community
    mysql-community-embedded-compat.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-icu-data-files.i686 8.0.30-1.el7 mysql80-community
    mysql-community-icu-data-files.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-libs.i686 8.0.30-1.el7 mysql80-community
    mysql-community-libs.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-libs-compat.i686 8.0.30-1.el7 mysql80-community
    mysql-community-libs-compat.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-release.noarch el7-5 mysql-connectors-community
    mysql-community-server.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-server-debug.x86_64 8.0.30-1.el7 mysql80-community
    mysql-community-test.x86_64 8.0.30-1.el7 mysql80-community
    mysql-connector-c++.x86_64 8.0.30-1.el7 mysql-connectors-community
    mysql-connector-c+±devel.x86_64 8.0.30-1.el7 mysql-connectors-community
    mysql-connector-c+±jdbc.x86_64 8.0.30-1.el7 mysql-connectors-community
    mysql-connector-java.noarch 1:8.0.30-1.el7 mysql-connectors-community
    mysql-connector-odbc.x86_64 8.0.30-1.el7 mysql-connectors-community
    mysql-connector-odbc-setup.x86_64 8.0.30-1.el7 mysql-connectors-community
    mysql-connector-python.noarch 2.0.4-1.el7 mysql-connectors-community
    mysql-connector-python.x86_64 8.0.23-1.el7 mysql-connectors-community
    mysql-connector-python-cext.x86_64 8.0.21-1.el7 mysql-connectors-community
    mysql-connector-python3.x86_64 8.0.30-1.el7 mysql-connectors-community
    mysql-connector-python3-cext.x86_64 8.0.21-1.el7 mysql-connectors-community
    mysql-ref-manual-8.0-en-html-chapter.noarch 1-20220707 mysql80-community
    mysql-ref-manual-8.0-en-pdf.noarch 1-20220707 mysql80-community
    mysql-router.x86_64 8.0.12-1.el7 mysql-tools-community
    mysql-router-community.x86_64 8.0.30-1.el7 mysql-tools-community
    mysql-shell.x86_64 8.0.30-1.el7 mysql-tools-community
    mysql-utilities.noarch 1.6.5-1.el7 mysql-tools-community
    mysql-utilities-extra.noarch 1.5.6-1.el7 mysql-tools-community
    mysql-workbench-community.x86_64

    多了很多,有MySQL8.0.30社区版了

    [root@VboxC7min2207 ~]# yum list mysql*
    已加载插件:fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.163.com
     * extras: mirrors.163.com
     * updates: mirrors.ustc.edu.cn
    可安装的软件包
    MySQL-python.x86_64                                                                                                                         1.2.5-1.el7                                                                                                                    base
    mysql-connector-java.noarch                                                                                                                 1:5.1.25-3.el7                                                                                                                 base
    mysql-connector-odbc.x86_64                                                                                                                 5.2.5-8.el7                                                                                                                    base
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]# sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
    已加载插件:fastestmirror
    mysql80-community-release-el7-7.noarch.rpm                                                                                                                                                                                                              |  11 kB  00:00:00
    正在检查 /var/tmp/yum-root-RCx9xf/mysql80-community-release-el7-7.noarch.rpm: mysql80-community-release-el7-7.noarch
    /var/tmp/yum-root-RCx9xf/mysql80-community-release-el7-7.noarch.rpm 将被安装
    正在解决依赖关系
    --> 正在检查事务
    ---> 软件包 mysql80-community-release.noarch.0.el7-7 将被 安装
    --> 解决依赖关系完成
    
    依赖关系解决
    
    ===============================================================================================================================================================================================================================================================================
     Package                                                                 架构                                                 版本                                                 源                                                                                     大小
    ===============================================================================================================================================================================================================================================================================
    正在安装:
     mysql80-community-release                                               noarch                                               el7-7                                                /mysql80-community-release-el7-7.noarch                                                10 k
    
    事务概要
    ===============================================================================================================================================================================================================================================================================
    安装  1 软件包
    
    总计:10 k
    安装大小:10 k
    Downloading packages:
    Running transaction check
    Running transaction test
    Transaction test succeeded
    Running transaction
      正在安装    : mysql80-community-release-el7-7.noarch                                                                                                                                                                                                                     1/1
      验证中      : mysql80-community-release-el7-7.noarch                                                                                                                                                                                                                     1/1
    
    已安装:
      mysql80-community-release.noarch 0:el7-7
    
    完毕!
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]#
    [root@VboxC7min2207 ~]# yum list mysql*
    已加载插件:fastestmirror
    Loading mirror speeds from cached hostfile
     * base: mirrors.163.com
     * extras: mirrors.163.com
     * updates: mirrors.ustc.edu.cn
    base                                                                                                                                                                                                                                                    | 3.6 kB  00:00:00
    extras                                                                                                                                                                                                                                                  | 2.9 kB  00:00:00
    mysql-connectors-community                                                                                                                                                                                                                              | 2.6 kB  00:00:00
    mysql-tools-community                                                                                                                                                                                                                                   | 2.6 kB  00:00:00
    mysql80-community                                                                                                                                                                                                                                       | 2.6 kB  00:00:00
    updates                                                                                                                                                                                                                                                 | 2.9 kB  00:00:00
    (1/4): mysql-connectors-community/x86_64/primary_db                                                                                                                                                                                                     |  90 kB  00:00:01
    (2/4): mysql-tools-community/x86_64/primary_db                                                                                                                                                                                                          |  87 kB  00:00:01
    (3/4): mysql80-community/x86_64/primary_db                                                                                                                                                                                                              | 211 kB  00:00:01
    (4/4): updates/7/x86_64/primary_db                                                                                                                                                                                                                      |  17 MB  00:00:04
    已安装的软件包
    mysql80-community-release.noarch                                                                                                  el7-7                                                                                                @/mysql80-community-release-el7-7.noarch
    可安装的软件包
    MySQL-python.x86_64                                                                                                               1.2.5-1.el7                                                                                          base
    mysql-community-client.i686                                                                                                       8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-client.x86_64                                                                                                     8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-client-plugins.i686                                                                                               8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-client-plugins.x86_64                                                                                             8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-common.i686                                                                                                       8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-common.x86_64                                                                                                     8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-devel.i686                                                                                                        8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-devel.x86_64                                                                                                      8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-embedded-compat.i686                                                                                              8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-embedded-compat.x86_64                                                                                            8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-icu-data-files.i686                                                                                               8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-icu-data-files.x86_64                                                                                             8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-libs.i686                                                                                                         8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-libs.x86_64                                                                                                       8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-libs-compat.i686                                                                                                  8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-libs-compat.x86_64                                                                                                8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-release.noarch                                                                                                    el7-5                                                                                                mysql-connectors-community
    mysql-community-server.x86_64                                                                                                     8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-server-debug.x86_64                                                                                               8.0.30-1.el7                                                                                         mysql80-community
    mysql-community-test.x86_64                                                                                                       8.0.30-1.el7                                                                                         mysql80-community
    mysql-connector-c++.x86_64                                                                                                        8.0.30-1.el7                                                                                         mysql-connectors-community
    mysql-connector-c++-devel.x86_64                                                                                                  8.0.30-1.el7                                                                                         mysql-connectors-community
    mysql-connector-c++-jdbc.x86_64                                                                                                   8.0.30-1.el7                                                                                         mysql-connectors-community
    mysql-connector-java.noarch                                                                                                       1:8.0.30-1.el7                                                                                       mysql-connectors-community
    mysql-connector-odbc.x86_64                                                                                                       8.0.30-1.el7                                                                                         mysql-connectors-community
    mysql-connector-odbc-setup.x86_64                                                                                                 8.0.30-1.el7                                                                                         mysql-connectors-community
    mysql-connector-python.noarch                                                                                                     2.0.4-1.el7                                                                                          mysql-connectors-community
    mysql-connector-python.x86_64                                                                                                     8.0.23-1.el7                                                                                         mysql-connectors-community
    mysql-connector-python-cext.x86_64                                                                                                8.0.21-1.el7                                                                                         mysql-connectors-community
    mysql-connector-python3.x86_64                                                                                                    8.0.30-1.el7                                                                                         mysql-connectors-community
    mysql-connector-python3-cext.x86_64                                                                                               8.0.21-1.el7                                                                                         mysql-connectors-community
    mysql-ref-manual-8.0-en-html-chapter.noarch                                                                                       1-20220707                                                                                           mysql80-community
    mysql-ref-manual-8.0-en-pdf.noarch                                                                                                1-20220707                                                                                           mysql80-community
    mysql-router.x86_64                                                                                                               8.0.12-1.el7                                                                                         mysql-tools-community
    mysql-router-community.x86_64                                                                                                     8.0.30-1.el7                                                                                         mysql-tools-community
    mysql-shell.x86_64                                                                                                                8.0.30-1.el7                                                                                         mysql-tools-community
    mysql-utilities.noarch                                                                                                            1.6.5-1.el7                                                                                          mysql-tools-community
    mysql-utilities-extra.noarch                                                                                                      1.5.6-1.el7                                                                                          mysql-tools-community
    mysql-workbench-community.x86_64                                                                                                  8.0.22-1.el7                                                                                         mysql-tools-community
    [root@VboxC7min2207 ~]#
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
    • 68
    • 69
    • 70
    • 71
    • 72
    • 73
    • 74
    • 75
    • 76
    • 77
    • 78
    • 79
    • 80
    • 81
    • 82
    • 83
    • 84
    • 85
    • 86
    • 87
    • 88
    • 89
    • 90
    • 91
    • 92
    • 93
    • 94
    • 95
    • 96
    • 97
    • 98
    • 99
    • 100
    • 101
    • 102
    • 103
    • 104
    • 105
    • 106
    • 107
    • 108
    • 109
    • 110
    • 111
    • 112
    • 113
    • 114
    • 115
    • 116
    • 117
    • 118
    • 119
    • 120
    • 121
    • 122
    • 123



    validate_password插件 和 validate_password组件

    MySQL8.0官方参考手册—密码验证组件—6.4.3 The Password Validation Component
    MySQL5.7官方参考手册—密码验证插件—6.4.3 The Password Validation Plugin

    组件和插件

    • MySQL5.7, 用的是 validate_password 插件
    • MySQL8.0, 用的是 validate_password 组件

    Ubuntu20.04下用apt安装的MySQL8.0默认没有使用validate_password 插件或组件
    CentOS7下用MySQL官方yum仓库安装的MySQL8.0默认启用validate_password 组件
    MySQL5.7的 validate_password 插件 在MySQL8.0中任然可以使用,但默认不使用,已过时,未来准备移除

    MySQL8.0的 validate_password 组件MySQL5.7 validate_password 插件功能取值
    validate_password.check_user_namevalidate_password_check_user_name检查密码与用户名是否相同或相反ON/OFF
    validate_password.dictionary_filevalidate_password_dictionary_file检查密码与密码字典字典文件路径
    validate_password.lengthvalidate_password_length检查密码长度0至正整数
    validate_password.mixed_case_countvalidate_password_mixed_case_count检查密密码大小写字母总数0至正整数
    validate_password.number_countvalidate_password_number_count检查密密码数字字符总数0至正整数
    validate_password.policyvalidate_password_policy密码策略,检查密码复杂度0、1、2 对应 LOW、MEDIUM、STRONG
    validate_password.special_char_countvalidate_password_special_char_count检查密码特殊字符的个数0至正整数

    可看到插件变量validate_password之后是下划线_ , 组件变量validate_password之后是点.
    插件的变量是相对独立的, 组件的变量被统一在validate_password之下

    validate_password.policyvalidate_password_policy 的取值

    `validate_password.policy` 和 `validate_password_policy` 的取值效果
    `validate_password.policy` 和 `validate_password_policy` 的取值效果
    取值效果
    0 或者 LOW只检查密码长度
    1 或者 MEDIUM检查长度; 数字、小写/大写和特殊字符
    2 或者 STRONG长度; 数字、小写/大写和特殊字符;字典文件
    取值效果
    0 或者 LOW只检查密码长度
    1 或者 MEDIUM检查长度; 数字、小写/大写和特殊字符
    2 或者STRONG长度; 数字、小写/大写和特殊字符;字典文件
    查看 validate_password 组件或插件的相关MySQL系统变量
    ### 查看 validate_password 的相关MySQL系统变量
    SHOW VARIABLES LIKE '%validate_password%';
    
    • 1
    • 2
    安装卸载 validate_password 组件

    mysql客户端执行

    安装 validate_password 组件
    ### 安装 validate_password 组件
    INSTALL COMPONENT 'file://component_validate_password';
    
    • 1
    • 2
    卸载 validate_password 组件
    ### 卸载 validate_password 组件
    UNINSTALL COMPONENT 'file://component_validate_password';
    
    • 1
    • 2
    安装卸载 validate_password 插件
    安装 validate_password 插件
    ### 安装 validate_password  插件
    INSTALL PLUGIN validate_password SONAME 'validate_password.so';
    
    • 1
    • 2
    卸载 validate_password 插件
    ### 卸载 validate_password  插件
    UNINSTALL PLUGIN validate_password;
    
    • 1
    • 2
    对比 validate_password 插件和组件的系统变量, “_“换成了”.”

    在组件和插件都没安装的情况下, 安装组件,查看相关变量, 安装插件,查看相关变量, 卸载组件, 查看相关变量

    mysql> ### 查看 validate_password 的相关MySQL系统变量
    mysql> SHOW VARIABLES LIKE '%validate_password%';
    Empty set (0.03 sec)
    
    mysql> ### 安装 validate_password 组件
    mysql> INSTALL COMPONENT 'file://component_validate_password';
    Query OK, 0 rows affected (0.08 sec)
    
    mysql> ### 查看 validate_password 的相关MySQL系统变量
    mysql> SHOW VARIABLES LIKE '%validate_password%';
    +--------------------------------------+--------+
    | Variable_name                        | Value  |
    +--------------------------------------+--------+
    | validate_password.check_user_name    | ON     |
    | validate_password.dictionary_file    |        |
    | validate_password.length             | 8      |
    | validate_password.mixed_case_count   | 1      |
    | validate_password.number_count       | 1      |
    | validate_password.policy             | MEDIUM |
    | validate_password.special_char_count | 1      |
    +--------------------------------------+--------+
    7 rows in set (0.00 sec)
    
    mysql> ### 安装 validate_password  插件
    mysql> INSTALL PLUGIN validate_password SONAME 'validate_password.so';
    Query OK, 0 rows affected, 1 warning (0.09 sec)
    
    mysql> ### 查看 validate_password 的相关MySQL系统变量
    mysql> SHOW VARIABLES LIKE '%validate_password%';
    +--------------------------------------+--------+
    | Variable_name                        | Value  |
    +--------------------------------------+--------+
    | validate_password.check_user_name    | ON     |
    | validate_password.dictionary_file    |        |
    | validate_password.length             | 8      |
    | validate_password.mixed_case_count   | 1      |
    | validate_password.number_count       | 1      |
    | validate_password.policy             | MEDIUM |
    | validate_password.special_char_count | 1      |
    | validate_password_check_user_name    | ON     |
    | validate_password_dictionary_file    |        |
    | validate_password_length             | 8      |
    | validate_password_mixed_case_count   | 1      |
    | validate_password_number_count       | 1      |
    | validate_password_policy             | MEDIUM |
    | validate_password_special_char_count | 1      |
    +--------------------------------------+--------+
    14 rows in set (0.00 sec)
    
    mysql> ### 卸载 validate_password 组件
    mysql> UNINSTALL COMPONENT 'file://component_validate_password';
    Query OK, 0 rows affected (0.08 sec)
    
    mysql> ### 查看 validate_password 的相关MySQL系统变量
    mysql> SHOW VARIABLES LIKE '%validate_password%';
    +--------------------------------------+--------+
    | Variable_name                        | Value  |
    +--------------------------------------+--------+
    | validate_password_check_user_name    | ON     |
    | validate_password_dictionary_file    |        |
    | validate_password_length             | 8      |
    | validate_password_mixed_case_count   | 1      |
    | validate_password_number_count       | 1      |
    | validate_password_policy             | MEDIUM |
    | validate_password_special_char_count | 1      |
    +--------------------------------------+--------+
    7 rows in set (0.00 sec)
    
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18
    • 19
    • 20
    • 21
    • 22
    • 23
    • 24
    • 25
    • 26
    • 27
    • 28
    • 29
    • 30
    • 31
    • 32
    • 33
    • 34
    • 35
    • 36
    • 37
    • 38
    • 39
    • 40
    • 41
    • 42
    • 43
    • 44
    • 45
    • 46
    • 47
    • 48
    • 49
    • 50
    • 51
    • 52
    • 53
    • 54
    • 55
    • 56
    • 57
    • 58
    • 59
    • 60
    • 61
    • 62
    • 63
    • 64
    • 65
    • 66
    • 67
  • 相关阅读:
    Web界面自动化操作工具 - Selenium常见用法
    Win10无法连接打印机怎么办?不能使用打印机的解决方法
    求二叉树中最大的二叉搜索子树的头节点
    1、SpringCloud大型企业分布式微服务云架构之Markdown 教程
    kubernetes通过配置hostAliases 实现pod解析指定host
    Llama2-Chinese项目:1-项目介绍和模型推理
    pip 时报错 no such option: --bulid-dir 的解决办法
    NET7下用WebSocket做简易聊天室
    react经典面试题解析
    变量和函数提升(js的问题)
  • 原文地址:https://blog.csdn.net/kfepiza/article/details/126900019