Connect Claude to MySQL with MCP
Use Claude with MySQL through MCP for schema discovery, read-only analysis, and faster SQL questions. Compare the direct MySQL server with Gateway-style alternatives, copy a safer starter config, and control the permission boundary.
Connect Claude to MySQL with MCP
If your goal is “let Claude inspect a MySQL database and answer SQL questions without giving it broad production write power,” this is the shortest path.
Recommended MCP servers for this use case
| Server | Best for | Not ideal when | Auth | Permission risk |
|---|---|---|---|---|
| MySQL MCP Server | Direct MySQL access, schema inspection, and query execution | You want a governed API layer instead of direct DB access | DB credentials | Medium |
| Centralmind Gateway | Teams that want a safer API-like layer between Claude and the database | You need the shortest possible local setup | Connection string + gateway config | Medium |
| Connect Claude to SQL Databases with MCP | Comparing MySQL against BigQuery, Snowflake, ClickHouse, or Fireproof | You already know MySQL is the target | Mixed | Medium |
Quick selection (30 seconds)
- Pick MySQL MCP Server if you want the most direct and readable MySQL setup.
- Pick Gateway if governance, PII filtering, or auditability matter more than setup speed.
- Start with a dedicated read-only MySQL user either way.
Copy-paste config (Claude Desktop)
{
"mcpServers": {
"mysql": {
"command": "uv",
"args": [
"--directory",
"/absolute/path/to/mysql_mcp_server",
"run",
"mysql_mcp_server"
],
"env": {
"MYSQL_HOST": "localhost",
"MYSQL_PORT": "3306",
"MYSQL_USER": "mcp_readonly_user",
"MYSQL_PASSWORD": "REPLACE_ME",
"MYSQL_DATABASE": "analytics"
}
}
}
}MySQL checklist
| Variable | Required | Sensitive | Notes |
|---|---|---|---|
MYSQL_HOST | Yes | No | Prefer a private hostname, not a public endpoint |
MYSQL_PORT | Optional | No | Defaults to 3306 in most setups |
MYSQL_USER | Yes | No | Use a dedicated least-privilege account |
MYSQL_PASSWORD | Yes | Yes | Keep out of repo files |
MYSQL_DATABASE | Yes | No | Scope to the smallest useful dataset |
First tool-call prompts
- “List all available tables and identify the five most relevant for product analytics.”
- “Run a read-only query for weekly active users in the last eight weeks.”
- “Explain this SQL result in plain English and highlight possible data quality issues.”
Risk and permission notes
- The main risk is not the MCP layer, but the database role you give it.
- Do not use root or a broad application user for the first rollout.
- If production is sensitive, test first against a staging replica or a restricted analytics schema.
FAQ
Should I choose direct MySQL MCP or Gateway?
Choose direct MySQL MCP for speed and simplicity. Choose Gateway if you need stronger audit, filtering, or policy controls between Claude and the database.
Can I allow writes later?
Yes, but only after read-only usage is stable and you have a narrow workflow that genuinely needs writes.
What is the fastest way to reduce risk?
Use a read-only MySQL user, scope the database tightly, and log early queries during rollout.
Related pages
Sources and freshness
- Sources: official server pages linked above.
- Updated: March 15, 2026.
Last updated on