zoukankan      html  css  js  c++  java
  • MySQL会话控制限制登录次数

    MySQL 5.7 以后提供了Connection-Control插件用来控制客户端在登录操作连续失败一定次数后的响应的延迟。
    该插件可有效的防止客户端暴力登录的风险(攻击)。该插件包含以下两个组件:
    
    connection_control:控制失败次数以及延迟时间
    connection_control_failed_login_attempts:将登录失败的操作记录至information_schema表
    
    
    
    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 = 5
    
    
    执行安装命令,使用root账户登录
    mysql> install plugin connection_control soname "connection_control.so";
    mysql> install plugin connection_control_failed_login_attempts soname "connection_control.so";
    
    
    验证插件安装状态
    mysql> select plugin_name, plugin_status from information_schema.plugins where plugin_name like 'connection%';
    +------------------------------------------+---------------+
    | plugin_name                              | plugin_status |
    +------------------------------------------+---------------+
    | CONNECTION_CONTROL                       | ACTIVE        |
    | CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS | ACTIVE        |
    +------------------------------------------+---------------+
    2 rows in set (0.00 sec)
    
    
    查看用户登录失败次数,当用户登录成功则删除记录
    mysql> select * from information_schema.connection_control_failed_login_attempts;
    
    
    连接控制的使用次数
    mysql> show global status like 'connection_control_delay_generated';
    
    
    超过失败次数如果想要马上登录,需要设置一下即可。
    mysql> set global connection_control_failed_connections_threshold=0;
    
    
    成功后别忘了改回来
    mysql> set global connection_control_failed_connections_threshold=5;
  • 相关阅读:
    各种版本控制器的作用
    mybatis的一些特殊符号标识(大于,小于,等于,不等于)
    struts2的作用是什么
    js中给数组添加元素的方法有哪些
    springmvc中拦截器配置格式
    js中require()的用法----JS如何连接数据库执行sql语句或者建立数据库连接池
    hover()函数的用法
    error和exception的不同与相同
    cookie和session的区别有哪些
    数据库连接池的工作机制是什么
  • 原文地址:https://www.cnblogs.com/l10n/p/14010188.html
Copyright © 2011-2022 走看看