设置方法
登录MySQL数据库
mysql-uroot-p
输入一下命令安装插件
install plugin CONNECTION_CONTROL soname 'connection_control.so';install plugin CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS soname 'connection_control.so';
修改MySQL配置文件/etc/my.cnf
vim /etc/my.cnf
在文件中新加以下两行
connection-control-failed-connections-threshold=5 #登陆失败次数限制connection-control-min-connection-delay=300000#限制重试时间,此处为毫秒,注意按需求换算,此处为5分钟
重启MySQL服务
systemctlrestartmysqld
重新登录数据库查看是否生效
show variables like '%connection_control%';
插件卸载命令
UNINSTALL PLUGIN CONNECTION_CONTROL;UNINSTALL PLUGIN CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS;
密码复杂度
show variables like ‘validate%’;
INSTALL PLUGIN validate_password SONAME ‘validate_password.so’;
#设置密码长度
set global validate_password_length = 10;
#validate_password_policy为MEDIUM,验证长度、数字、大小写、特殊字符
·登陆失败处理
install plugin CONNECTION_CONTROL soname ‘connection_control.so’;
install plugin CONNECTION_CONTROL_FAILED_LOGIN_ATTEMPTS soname ‘connection_control.so’;
show variables like ‘connection_control%’;
#设置最大失败次数
set global connection_control_failed_connections_threshold=3;
#设置最小等待时间(1000ms)
set global connection_control_min_connection_delay=300000;
#永久保存策略
vi xx/my.cnf
plugin-load-add = validate_password.so
plugin-load-add = connection_control.so
validate_password_length = 10
validate_password_policy = 1
validate-password = FORCE_PLUS_PERMANENT
connection_control_failed_connections_threshold=3
connection_control_min_connection_delay=300000