
1、密码有效期设置my.inidefault_password_lifetime90命令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.iniplugin-load-addvalidate_password.dllvalidate_password_policy1validate_password_length8validate_password_check_user_nameON命令INSTALL PLUGIN validate_password SONAME validate_password.dll;SET GLOBAL validate_password_policy1;SET GLOBAL validate_password_length8;set global validate_password_check_user_name ON ;查看密码复杂度show VARIABLES like %validate_password%;3、登录失败处理策略登录失败次数不超过5次账号锁定时间不少于10分钟my.iniplugin-load-addconnection_control.dllconnection_control_failed_connections_threshold5connection_control_min_connection_delay600000命令install plugin connection_control soname connection_control;install plugin connection_control_failed_login_attempts soname connection_control;SET GLOBAL connection_control_failed_connections_threshold5;SET GLOBAL connection_control_min_connection_delay600000;查看登录失败处理策略show variables like %connection_control%;4、开启日志my.iniserver-id1log-binmysql-binbinlog-formatRowexpire_logs_days 7log-outputFILEgeneral-log1general_log_fileHE-VM-0000000001.logslow-query-log1slow_query_log_fileHE-VM-0000000001-show.loglong_query_time10