mysql设置密码复杂度策略,登录失败次数限制

在配置文件中加入如下配置,重启mysql服务

[mysqld]
#密码复杂度插件
plugin-load-add=validate_password.so
validate-password=FORCE_PLUS_PERMANENT
validate_password_policy=2 # 0简单 1普通 2困难
validate_password_length=9 # 密码长度限制
#登录失败次数、时间限制插件
plugin-load-add					= connection_control.so
connection-control                             	= FORCE
connection-control-failed-login-attempts       	= FORCE
connection_control_min_connection_delay		= 10000 # 超过失败次数后的最小等待时间 毫秒
connection_control_max_connection_delay		= 20000
connection_control_failed_connections_threshold	= 5 # 5次后限制登录

测试密码复杂度

创建用户

CREATE USER 'username'@'localhost' IDENTIFIED BY 'password'
> 1819 - Your password does not satisfy the current policy requirements
> 时间: 0.095s

查看插件位置show variables like 'plugin_dir';

查看密码验证变量:
show variables like ‘validate_password%’;在这里插入图片描述

验证登录失败次数限制

先登录失败几次

bash-4.2# mysql -uroot -p111
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)
bash-4.2# mysql -uroot -p111
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)

达到限制后会进行等待,还可查看登录失败信息:

select * from information_schema.connection_control_failed_login_attempts;

在这里插入图片描述

  • 4
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值