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组件,密码强度要求变态,注意可能以括号开头,是密码的一部分



文章目录

    • CentOS7用yum安装MySQL8.0 2209170054
    • 本次不使用安装包安装, 而是yum配置包配置yum后,用yum安装
      • 第一步,下载并使用`mysql80-community-release-el7-7.noarch.rpm` 配置yum
        • 可以直接用yum下载并安装这个文件
        • 也可以分步
      • 第二步, 此时就能用yum安装新版MySQL了
      • 第三步, 启动`mysqld`服务
      • 第四步, 查看生成的root变态密码, 用变态密码登录
        • 查看生成的初始变态密码 `grep 'temporary password' /var/log/mysqld.log;`
        • 用初始密码登录
      • 第五步, 登录后,必须修改密码才能执行其它操作
      • 第六步,修改初始密码后, 可以设置降低密码强度, 使用简单密码
        • 可选:降低 validate_password 组件对密码强度的要求
        • 可选: 卸载 validate_password 组件
      • 第七步, 创建远程用户,开放防火墙端口3306
        • 创建远程用户
        • 开放 firewalld 防火墙的3306端口
      • 用脚本安装
        • CentOS7一步安装MySQL8.0并且第一次登录
        • CentOS7一步安装MySQL8.0并且将root@localhost免密
        • CentOS7一步安装MySQL8.0并且将root@localhost免密, 创建免密的remote用户, 开放3306端口
    • 题外
      • 对比 , 在执行`sudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm`前, 和执行后, `yum list mysql*`的变化
      • validate_password插件 和 validate_password组件
        • 查看 validate_password 组件或插件的相关MySQL系统变量
        • 安装卸载 validate_password 组件
          • 安装 validate_password 组件
          • 卸载 validate_password 组件
        • 安装卸载 validate_password 插件
          • 安装 validate_password 插件
          • 卸载 validate_password 插件
        • 对比 validate_password 插件和组件的系统变量, "_"换成了"."

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

  • MySQL安装包的下载地址—https://dev.mysql.com/downloads/mysql/,
    还有
  • YUM仓库安装MySQL的配置包的下载地址—https://dev.mysql.com/downloads/repo/yum/

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

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

CentOS7用yum安装MySQL8.0 2209170054_第1张图片

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

第一步,下载并使用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. 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

或者

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

效果一样



第三步, 启动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

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;

例如

[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

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

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

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

用初始密码登录

手动输入密码

mysql -uroot -p

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

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

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

[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)

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

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

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

设置密码方法2

SET PASSWORD='ABCDEFGhijklmn1234567!!!';

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

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

  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%';


可选: 卸载 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';

然后就能设为空密码

ALTER USER root@localhost IDENTIFIED BY '';

SET PASSWORD='';

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




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

创建远程用户

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

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

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

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

赋予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;

开放 firewalld 防火墙的3306端口

sudo firewall-cmd --zone=public --permanent --add-port=3306/tcp ; sudo systemctl restart firewalld ;

用脚本安装

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

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

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




题外

对比 , 在执行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*

可见, 在执行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 ~]#



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_name validate_password_check_user_name 检查密码与用户名是否相同或相反 ON/OFF
validate_password.dictionary_file validate_password_dictionary_file 检查密码与密码字典 字典文件路径
validate_password.length validate_password_length 检查密码长度 0至正整数
validate_password.mixed_case_count validate_password_mixed_case_count 检查密密码大小写字母总数 0至正整数
validate_password.number_count validate_password_number_count 检查密密码数字字符总数 0至正整数
validate_password.policy validate_password_policy 密码策略,检查密码复杂度 0、1、2 对应 LOW、MEDIUM、STRONG
validate_password.special_char_count validate_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%';

安装卸载 validate_password 组件

在mysql客户端执行

安装 validate_password 组件
### 安装 validate_password 组件
INSTALL COMPONENT 'file://component_validate_password';
卸载 validate_password 组件
### 卸载 validate_password 组件
UNINSTALL COMPONENT 'file://component_validate_password';

安装卸载 validate_password 插件

安装 validate_password 插件
### 安装 validate_password  插件
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
卸载 validate_password 插件
### 卸载 validate_password  插件
UNINSTALL PLUGIN validate_password;

对比 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)

你可能感兴趣的:(#,关系型SQL,MySql,MsSql,Oracle,#,Linux,CentOS,Ubuntu,等,安装软件,开发环境搭建,mysql,数据库,服务器)