MySQL User Privilege & Access Hardening Prompt
Audit MySQL/MariaDB users, grants, and host patterns for least privilege: find wildcard hosts, anonymous and password-less accounts, over-broad GRANTs, and risky global privileges, then produce a safe remediation plan.
- Target user
- DBAs and security/compliance engineers
- Difficulty
- Intermediate
- Tools
- Claude, ChatGPT
The prompt
You are a senior MySQL DBA running a least-privilege and access-hardening review against a compliance baseline.
I will provide:
- `SELECT user, host, plugin, authentication_string='' AS no_password FROM mysql.user;`
- `SHOW GRANTS FOR 'user'@'host';` for the key accounts (or the dump of mysql.user/db/tables_priv)
- Output of `mysql_secure_installation` state if known, and whether anonymous users / test DB still exist
- The application's actual access pattern (which schemas/tables each service touches, read vs write)
- Auth/TLS config: require_secure_transport, default_authentication_plugin, password validation settings
Your job:
1. **Flag the dangerous accounts** — anonymous (''@host) users, accounts with empty authentication_string, root reachable from '%' or non-localhost, and shared/service accounts with broad hosts.
2. **Audit privilege scope** — identify GRANTs that exceed need: global ALL PRIVILEGES, SUPER/PROCESS/FILE/SHUTDOWN/GRANT OPTION where not required, and `*.*` grants that should be schema- or table-scoped.
3. **Tighten host patterns** — replace `'%'` with specific subnets/hosts where feasible and explain the trade-off for cloud/dynamic IPs (use a bastion or proxy instead of wildcards).
4. **Enforce auth quality** — recommend password validation policy, caching_sha2_password, and require_secure_transport/TLS for accounts crossing the network.
5. **Produce remediation** — give the exact REVOKE/CREATE USER/ALTER USER/DROP USER statements, ordered so you never lock out admin access, plus a verification query.
Output as: (a) risk-ranked findings, (b) least-privilege grant proposal per account, (c) ordered remediation SQL, (d) verification, (e) rollback note.
Advisory only: present the SQL for review — do not auto-apply REVOKE/DROP, and always confirm an alternate admin path exists before tightening root or removing accounts.
Run this prompt with AI
Test it, get an AI-improved version, or compare models — live in the Prompt Workspace. No copy-paste.
Related prompts
-
MySQL caching_sha2_password Auth Migration Prompt
Plan migrating accounts from mysql_native_password to caching_sha2_password without locking out legacy drivers or non-TLS clients.
-
MySQL TLS / Encrypted Connection Hardening Prompt
Enforce encrypted client and replication connections with proper certificates and require_secure_transport without locking out existing apps.
-
MySQL InnoDB Buffer Pool Warmup Prompt
Configure buffer-pool dump/restore so a restarted or failed-over MySQL instance serves warm-cache latency immediately instead of a cold-cache stall.
-
MySQL Durability & Flush Settings Tuning Prompt
Balance InnoDB durability against throughput by reviewing flush, sync, and doublewrite settings for a given workload and hardware.
More MySQL prompts & error guides
Browse every MySQL prompt and troubleshooting guide in one place.
Reading prompts? Get all 500 in one free PDF
500 battle-tested, copy-paste AI prompts engineered by a senior systems engineer — every one with fill-in placeholders and safety/back-out notes. Drop your email and it's yours.
- 500 prompts: Linux · Kubernetes · Terraform · OpenStack · GitLab · Docker · Monitoring · Incident Response
- Instant PDF download — yours free, forever
- Plus one practical AI-workflow email a week (no spam)
Single opt-in · unsubscribe anytime · no spam.