| 用途 | 账号安全巡检 |
|---|---|
| 检查项 | 匿名/空密码/%/过度授权/锁定/长期未用 |
| 输出 | 问题清单 + 整改动作 |
基线检查 SQL
基线检查 SQL
-- 匿名与空密码
SELECT user, host, authentication_string FROM mysql.user WHERE user='' OR authentication_string='';
-- 全网可达账号
SELECT user, host FROM mysql.user WHERE host='%';
-- 锁定与过期
SELECT user, host, account_locked, password_expired FROM mysql.user;
-- 过度授权(示例:普通账号拿到全局权限)
SELECT grantee, privilege_type FROM information_schema.user_privileges WHERE grantee NOT LIKE "'root'%";把上述查询固化成审计脚本定期跑,比一年一次的「大检查」更能暴露缓慢积累的权限漂移。