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'; #为了把错误次数记录到表中

 

三、设置插件

查询一下安装状态

解释:

  • 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

五、查询插件状态

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

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

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

use information_schema;
select * from connection_control_failed_login_attempts;

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

猜你喜欢

转载自blog.csdn.net/sumengnan/article/details/114111579
今日推荐