Dedicated MySQL account
A separate user-and-host identity instead of root, an application owner, or a shared administrative login.
Free MySQL security resource
A reusable SQL template for restricting AI tools, agents, and MCP clients at the MySQL account boundary. Match a precise user and host, require encrypted transport, grant only reviewed tables, then prove both allowed and denied behavior.
Review every account, host, identifier, and statement before use. The file contains documentation placeholders, not a production password or a universal network configuration.
After the download
Keep the database account from the kit as the backend boundary. Connect it to datamcp, create a separate MCP link, and choose the client-facing permissions before adding the endpoint to your AI tool.
Apply and test the restricted account
Replace every placeholder, then verify both allowed and denied operations.
Connect the database
Use the restricted account rather than an owner or administrative credential.
Create and test the MCP link
Start with the narrowest client permissions and verify the link from the intended MCP client.
What is included
A separate user-and-host identity instead of root, an application owner, or a shared administrative login.
A documentation-only host placeholder, REQUIRE SSL, and a reviewed connection limit.
SELECT on named relations rather than global privileges or an unreviewed database wildcard.
A commented example for exposing only reviewed columns when table-wide SELECT is too broad.
USER(), CURRENT_USER(), SHOW CREATE USER, and SHOW GRANTS review points.
Reads, sensitive tables, writes, DDL, routines, and newly created tables.
Account lock, targeted REVOKE, full direct-grant revocation, and a reviewed unlock path.
Validation matrix
Run the commented checks one at a time against disposable fixtures or an approved test environment. Confirm both USER() and CURRENT_USER(): MySQL authorizes the account row it matched, which may differ from the identity string the client supplied.
| Test | Expected |
|---|---|
| Approved table SELECT | Allowed |
| Sensitive table SELECT | Denied |
| INSERT, UPDATE, DELETE | Denied unless explicitly granted |
| CREATE or DROP table | Denied |
| Stored routine execution | Denied unless explicitly granted |
| New table after migration | Denied until reviewed and granted |
Primary references
The kit follows MySQL's account and privilege statements. Provider policies, supported authentication plugins, TLS configuration, and network rules still require separate review.
Add a separate client boundary
A hosted MCP gateway can add separate client authentication, narrower link permissions, activity review, and independent revocation. It should not replace the restricted MySQL account from this kit.