我用的percona-server5,在/etc/my.cnf中添加
general_log_file=/var/log/mysql-logerr.log
general_log=1
开启了登录错误的日志,日志的格式如下
160419 19:52:40 1 Connect newer@192.168.56.1 on
1 Connect Access denied for user 'newer'@'192.168.56.1' (using password: NO)
160419 19:52:47 2 Connect newer@192.168.56.1 on
2 Connect Access denied for user 'newer'@'192.168.56.1' (using password: YES)
fail2ban中开启mysqld-auth,然后用
fail2ban-regex /var/log/mysql-logerr.log /etc/fail2ban/filter.d/mysqld-auth.conf
进行测试,发现无法成功屏蔽IP,已经知道是/etc/fail2ban/filter.d/mysqld-auth.conf中的正则有问题,请问该如何修改?
原有的正则如下
failregex = ^%(__prefix_line)s(\d{6} \s?\d{1,2}:\d{2}:\d{2} )?\[Warning\] Access denied for user '\w+'@'' (to database '[^']*'|\(using password: (YES|NO)\))*\s*$