1、密码有效期设置:
my.ini:default_password_lifetime=90
命令:SET GLOBAL default_password_lifetime = 90;
查看密码有效期:SHOW VARIABLES LIKE 'default_password_lifetime';
查看所有账号有效期状态:
select user,host,password_expired,password_last_changed,password_lifetime from mysql.user;
业务账号设置永不过期(强烈建议,防止定时任务、应用炸掉):
ALTER USER '用户名'@'localhost' PASSWORD EXPIRE NEVER;
2、密码复杂度设置:
my.ini:
plugin-load-add=validate_password.dll
validate_password_policy=1
validate_password_length=8
validate_password_check_user_name=ON
命令:
INSTALL PLUGIN validate_password SONAME 'validate_password.dll';
SET GLOBAL validate_password_policy=1;
SET GLOBAL validate_password_length=8;
set global validate_password_check_user_name = ON ;
查看密码复杂度:show VARIABLES like '%validate_password%';
3、登录失败处理策略,登录失败次数不超过5次,账号锁定时间不少于10分钟:
my.ini:
plugin-load-add=connection_control.dll
connection_control_failed_connections_threshold=5
connection_control_min_connection_delay=600000
命令:
install plugin connection_control soname 'connection_control';
install plugin connection_control_failed_login_attempts soname 'connection_control';
SET GLOBAL connection_control_failed_connections_threshold=5;
SET GLOBAL connection_control_min_connection_delay=600000;
查看登录失败处理策略:show variables like '%connection_control%';
4、开启日志:
my.ini:
server-id=1
log-bin=mysql-bin
binlog-format=Row
expire_logs_days = 7
log-output=FILE
general-log=1
general_log_file="HE-VM-0000000001.log"
slow-query-log=1
slow_query_log_file="HE-VM-0000000001-show.log"
long_query_time=10