Ubuntu20.04安装MySQL很轻松, apt install mysql-server就搞定了
CentOS7安装MySQL很麻烦, 不能用yum直接安装, 要下载mysql官方的安装包或yum仓库配置,
apt安装的mysql不带validate_password
组件
yum安装的mysql带validate_password
组件,密码强度要求变态,注意可能以括号开头,是密码的一部分
MySQL的官方下载, 不但有安装包, 还有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
mysql80-community-release-el7-7.noarch.rpm
配置yumsudo yum install -y https://dev.mysql.com/get/mysql80-community-release-el7-7.noarch.rpm
sudo yum install -y mysql-server
或者
sudo yum install -y mysql-community-server.x86_64
效果一样
mysqld
服务CentOS的mysql服务是mysqld
, Ubuntu是mysql
systemctl start mysqld
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
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!!!';
降低密码强度要求的方法有
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 组件
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就能直接登录
创建一个名为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;
sudo firewall-cmd --zone=public --permanent --add-port=3306/tcp ; sudo systemctl restart firewalld ;
#!/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
#!/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
#!/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 ~]#
MySQL8.0官方参考手册—密码验证组件—6.4.3 The Password Validation Component
MySQL5.7官方参考手册—密码验证插件—6.4.3 The Password Validation Plugin
组件和插件
插件
组件
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.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系统变量
SHOW VARIABLES LIKE '%validate_password%';
在mysql客户端执行
### 安装 validate_password 组件
INSTALL COMPONENT 'file://component_validate_password';
### 卸载 validate_password 组件
UNINSTALL COMPONENT 'file://component_validate_password';
### 安装 validate_password 插件
INSTALL PLUGIN validate_password SONAME 'validate_password.so';
### 卸载 validate_password 插件
UNINSTALL PLUGIN 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)