Connect MySQL to ChatGPT with a production connection preflight
The connection test says “success.” ChatGPT still cannot see the right tables—or it can see far more than intended.
A TCP handshake and SELECT 1 prove reachability. A production connection preflight proves the identity, scope, session, and failure behavior that the AI workflow will actually use.
1. Verify the effective identity
Connect with the exact service credential used by the tool, then record authenticated user, effective grants, database, host, and environment. Do not test as an administrator and deploy as a restricted account. Use a dedicated identity rather than a shared human credential.
For the broader architecture, see MCP server for MySQL AI agents.
2. Prove TLS, not just encryption
Require certificate and hostname verification, confirm the expected CA chain, and fail closed when trust is broken. Test an expired certificate, wrong hostname, untrusted CA, and accidental plaintext configuration. “Encrypted” is not enough if the client accepts the wrong server.
3. Enumerate the visible schema
Ask the connection which schemas, tables, views, routines, and columns it can discover. Compare that inventory with an approved manifest. Schema discovery and query execution may need different permissions; neither should silently inherit global visibility.
Use approved views to remove irrelevant or sensitive fields before they enter model context. The pattern is described in approved views for AI database agents.
4. Pin session semantics
Verify time zone, SQL mode, character set, collation, transaction isolation, statement timeout or equivalent enforcement, and read-only behavior. Capture them at connection checkout and reset pooled sessions after every success, error, cancellation, and timeout.
A detailed companion is the MySQL session settings contract.
5. Test the allowed query surface
Run a small approved aggregate, a bounded detail lookup, and a join through an approved view. Verify tenant/environment scope, deterministic ordering, row and byte limits, truncation metadata, freshness, cancellation, and audit evidence.
Then try the negative paths: SELECT * from a sensitive table, an unbounded time range, a write, a DDL statement, an expensive cross join, and a request for another tenant. The expected result is a structured refusal or bounded error—not fluent improvisation.
6. Return a preflight receipt
Record connection target identity, TLS verification result, principal, approved schema-manifest version, session settings, read-only status, limit policy, test-suite version, checks passed/failed, and trace ID. Keep secrets and raw sensitive values out of the receipt.
Concrete acceptance sequence
- Create the least-privilege MySQL identity.
- Validate TLS and effective grants.
- Diff visible schema against the approved manifest.
- Assert session settings on a fresh and reused connection.
- Run positive and negative query fixtures.
- Force cancellation and confirm the connection returns clean.
- Approve production use only with a complete receipt.
Where Conexor fits
Conexor provides MCP infrastructure for connecting ChatGPT and other AI clients to databases and APIs through governed tools. A connection preflight keeps identity, schema context, query limits, and evidence explicit before questions reach production data.