Free MySQL security resource

MySQL AI Access Security Kit

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

Turn the restricted MySQL account into a hosted MCP link

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.

  1. 01

    Apply and test the restricted account

    Replace every placeholder, then verify both allowed and denied operations.

  2. 02

    Connect the database

    Use the restricted account rather than an owner or administrative credential.

  3. 03

    Create and test the MCP link

    Start with the narrowest client permissions and verify the link from the intended MCP client.

What is included

One account boundary, reviewed end to end

Dedicated MySQL account

A separate user-and-host identity instead of root, an application owner, or a shared administrative login.

Host and TLS boundary

A documentation-only host placeholder, REQUIRE SSL, and a reviewed connection limit.

Explicit table grants

SELECT on named relations rather than global privileges or an unreviewed database wildcard.

Optional column scope

A commented example for exposing only reviewed columns when table-wide SELECT is too broad.

Effective-account checks

USER(), CURRENT_USER(), SHOW CREATE USER, and SHOW GRANTS review points.

Allowed and denied tests

Reads, sensitive tables, writes, DDL, routines, and newly created tables.

Emergency controls

Account lock, targeted REVOKE, full direct-grant revocation, and a reviewed unlock path.

Validation matrix

A successful SELECT proves only one path

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.

TestExpected
Approved table SELECTAllowed
Sensitive table SELECTDenied
INSERT, UPDATE, DELETEDenied unless explicitly granted
CREATE or DROP tableDenied
Stored routine executionDenied unless explicitly granted
New table after migrationDenied until reviewed and granted

Primary references

Check the behavior against MySQL

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

MySQL grants remain an independent enforcement layer

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.

Explore datamcp MySQL MCP