---
title: "MySQL MCP Server Setup Guide and Schema"
slug: "mysql"
category: "databases"
package: "@benborla29/mcp-server-mysql"
transport: "stdio"
canonical: "https://mcp-codex.com/servers/mysql"
source: "MCP Codex (https://mcp-codex.com)"
dateModified: "2026-09-28"
---

# MySQL MCP Server

> Query MySQL databases, inspect schemas, and run read-only operations.

## Overview
Enable AI agents to connect to MySQL databases for schema inspection, query execution, and data exploration. Community-maintained server supporting connection pooling and configurable access controls.

## Quick Install
```bash
npx -y @benborla29/mcp-server-mysql
```

## Environment Variables

| Variable | Description | Required |
| :--- | :--- | :--- |
| `MYSQL_HOST` | MySQL server hostname | **Yes** |
| `MYSQL_USER` | Database username | **Yes** |
| `MYSQL_PASSWORD` | Database password | **Yes** |
| `MYSQL_DATABASE` | Database name | **Yes** |

## Client Configurations

### Claude Desktop (`claude_desktop_config.json`)
```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "",
        "MYSQL_DATABASE": "mydb"
      }
    }
  }
}
```

### Cursor (`mcp.json`)
```json
{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@benborla29/mcp-server-mysql"
      ],
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_USER": "root",
        "MYSQL_PASSWORD": "",
        "MYSQL_DATABASE": "mydb"
      }
    }
  }
}
```

### OpenAI Codex CLI (`~/.codex/config.toml`)
```toml
[mcp_servers.mysql]
command = "npx"
args = ["-y", "@benborla29/mcp-server-mysql"]

[mcp_servers.mysql.env]
MYSQL_HOST = "localhost"
MYSQL_USER = "root"
MYSQL_PASSWORD = ""
MYSQL_DATABASE = "mydb"
```

## Available Tools (1)

- `query`

## Documentation & Links
- Canonical Web Page: https://mcp-codex.com/servers/mysql
- Weekly Protocol Changelog: https://mcp-codex.com#newsletter
- GitHub Repository: https://github.com/benborla/mcp-server-mysql
- Setup Tutorial Guide: https://mcp-codex.com/articles/mysql-mcp-server-guide

