MariaDB 开启密码复杂度和密码过期策略

MariaDB 开启密码复杂度和密码过期策略
 
MariaDB 版本:10.4.21及以上
 
sql语句设置方式(重启失效)
#安装启用
INSTALL SONAME 'simple_password_check';
#检查验证
show variables like '%password%';
 
set global simple_password_check_minimal_length=8;
 
set global simple_password_check_other_characters=1;
 
set global simple_password_check_letters_same_case=1;
 
set global simple_password_check_digits=1;
 
配置文件设置方式
vim /etc/my.cnf.d/server.cnf  
#配置文件添加如下参数
[mysqld]
#加载密码复杂度审计插件
plugin-load=simple_password_check.so
#密码长度,默认8位
simple_password_check_minimal_length=8
#特殊符号,1代表至少1位
simple_password_check_other_characters=1
#字母数,1代表至少1位
simple_password_check_letters_same_case=1
#数字数,1代表至少1位
simple_password_check_digits=1
#默认密码过期时间 单位天 每过180天就要修改密码
default_password_lifetime=180
#最大错误登录次数
max_password_errors=5
 
 
 
#sql语句设置用户密码过期时间
##密码有效期设置 sql语句
create user 'test'@'localhosts' identified by '123QWe!@#'  password expire interval 30 day;     #30天过期
create user 'test'@'localhost' password expire never;                                           #永不过期
alter user 'test'@'localhost' password expire interval 120 DAY;                                 #修改为120天过期
alter user 'test'@'localhost' password expire never;                                            #修改为永不过期
 

 

 
posted @ 2022-08-30 11:17  缤纷世界  阅读(1663)  评论(0编辑  收藏  举报