dataiotech Labs
dbaguidedbaguideDBAdataxtoolsdataopsphere
Scripts Library/mysql/#35
Script #35
mysql
Securityread-only (mysql.user okuma yetkisi)Min Version: 5.7

Risky MySQL User Accounts and Excess Privileges

Finds accounts with no password, open host access, or dangerous privileges like SUPER and FILE. A baseline check for security audits.

#users#privileges#hardening
mysql · sql
SELECT user, host, plugin,
       (authentication_string = '') AS no_password,
       account_locked, password_expired
FROM mysql.user
WHERE authentication_string = '' OR host = '%'
ORDER BY user;

SELECT grantee, privilege_type, is_grantable
FROM information_schema.user_privileges
WHERE privilege_type IN ('SUPER','FILE','SHUTDOWN','PROCESS')
ORDER BY grantee;
Operational Notes & Remediation Guidance

Eliminate wildcard host accounts (`%`) for administrative users and revoke unnecessary global privileges.

Production Safety & Execution Standards
  • This script is designed for read-only diagnostics; it does not alter schema or modify data directly.
  • Prior to executing on production systems under high load, verify the target database version (Min. Version: 5.7).
  • Exercise caution with mutating actions (e.g., terminating sessions or dropping indexes) referenced in the notes section.