mysql安装connection_control限制登录次数插件

Connection-Control插件用来控制客户端在登录操作连续失败一定次数后的响应的延迟。可防止客户端暴力破解。

 

一、查询插件是否安装

如果有connection_control则已安装,没有则继续下一步。

 

二、安装插件

在mysql5.7后mysql/data/lib/plugin目录默认增加了connection_control.so插件,安装即可:

install plugin connection_control soname "connection_control.so"; #登录错误次数限制插件
install plugin connection_control_failed_login_attempts soname 'connection_control.so'; #为了把错误次数记录到表中

 

三、设置插件

查询一下安装状态show variables like "%connection_control%";

解释:

  • connection_control_failed_connections_threshold :连续失败最大次数3次,0表示不开启
  • connection_control_max_connection_delay :超过最大失败次数之后阻塞登录最大时间(毫秒)
  • connection_control_min_connection_delay :超过最大失败次数之后阻塞登录最小时间(毫秒)

修改配置命令:set global connection_control_failed_connections_threshold=5

 

四、修改my.cnf配置文件

[mysqld]
plugin-load-add = connection_control.so
connection-control = FORCE
connection-control-failed-login-attempts = FORCE
connection_control_min_connection_delay = 1000
connection_control_max_connection_delay = 86400
connection_control_failed_connections_threshold	= 3

 

五、查询插件状态

show status like "%connection_control%";

Connection_control_delay_generated:表示连接控制的使用次数(可用户判断是否存在暴力登录尝试)

重新配置connection_control_failed_connections_threshold变量,该表记录会被删除(重置)

SET GLOBAL connection_control_failed_connections_threshold = 3;

六、查询各账号登录失败次数

use information_schema;
select * from connection_control_failed_login_attempts;

如果使用不存在的用户登录,则该表记录用户名为空,但会记录具体登录的IP

 

 

  • 12
    点赞
  • 45
    收藏
    觉得还不错? 一键收藏
  • 4
    评论
评论 4
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值