mysql-mcp-pro

Production-grade MySQL MCP Server installation and configuration assistant that can enable 25 professional database tools with one action. Supports connection pool, transactions, EXPLAIN analysis, CSV export, ER diagrams, and audit logging (performs installation/configuration and tool enablement as specified).

Installation

Review the source and dependencies with a prompt. A package is available to download.

Install with an AI assistant

Copy the prompt so your assistant can review the pinned revision and dependencies first.

View promptHide prompt
Check whether SkillPI Skill Finder is installed for your current agent. If it is missing, install and enable it using the official instructions at https://github.com/Findskills/skillpi. Then use Skill Finder to locate and install "mysql-mcp-pro" from this exact SkillPI detail page: https://skillpi.com/skills/deepskill-6768cfaac59db6699e294f1de17a4b49b91ad3986a152e61031c4f0a31a0d368. Verify the upstream source and version against https://skillhub.cn/skills/user_b710a0b0/mysql-mcp-pro before installing. If they do not match, stop and report the mismatch. Report the installed path and source version.

Source and setup

skillhub.cn

Setup guidance pending

See the original source for supported tools, dependencies, and permissions.

Installation test pending

Production-grade MySQL MCP Server installation and configuration assistant that can enable 25 professional database tools with one action. Supports connection pool, transactions, EXPLAIN analysis, CSV export, ER diagrams, and audit logging (performs installation/configuration and tool enablement as specified).

0 Downloads

Introduction source: third_party · user_b710a0b0 · 2.0.1 Reference

SkillPi interpretation

Tasks
Translation pending; see source documentation.
Audience
Translation pending; see source documentation.
Inputs and outputs
Translation pending; see source documentation.
Software, accounts and paid services
Translation pending; see source documentation.
Testing
Not tested

Browse files

Browse files at the source ↗

Original SKILL.md

Open original ↗
Frontmatter
name: mysql-mcp-pro
description: |
  将 mysql-mcp-pro(生产级 MySQL MCP Server)安装并配置到你的 AI 客户端(WorkBuddy/Claude Desktop/Cursor/Cline)。
  安装后 AI 将拥有 25 个专业数据库工具:库表浏览、结构查看、SQL 执行(安全分级)、只读 SELECT、分页取数、EXPLAIN 执行计划中文解读、CSV/JSON 导出、事务支持、进程管理、服务器状态监控等。
  内置连接池、参数化查询防注入、危险语句拦截、审计日志等生产级安全机制。
  触发场景:连接 MySQL、查数据库、看表结构、执行 SQL、分析慢查询、导出数据、做报表、数据库概览、ER 关系图。
slug: mysql-mcp-pro
displayName: MySQL 专业数据库助手(MCP)
version: 2.0.1
summary: 生产级 MySQL MCP Server 安装配置助手 — 一键启用25个专业数据库工具,支持连接池/事务/EXPLAIN分析/CSV导出/ER关系图/审计日志
license: MIT
tags:
- mysql
- database
- mcp
- sql
- dba
- data-analysis
- claude
- cursor
author: CCCT173
homepage: https://github.com/CCCT173/mysql-mcp-pro

MySQL 专业数据库助手(mysql-mcp-pro MCP)

把生产级 MySQL MCP Server 装进你的 AI 客户端,让 AI 直接操作 MySQL 数据库——安全、可审计、带连接池和事务。

🎯 使用场景

当用户提到以下需求时使用本 skill:

  • "连接我的 MySQL 数据库" / "安装 MySQL MCP"
  • "查看数据库里的表" / "看一下表结构"
  • "执行这条 SQL" / "帮我查一下数据" / "导出数据"
  • "分析一下这条 SQL 性能怎么样" / "为什么这么慢"
  • "生成一条查询语句" / "做个数据库概览报告"
  • "画一下表之间的关系" / "ER 图"
  • "开启事务操作一批数据" / "回滚刚才的操作"

✨ 启用后 AI 会拥有的 25 个工具

类别 工具 功能
连接 ping 测试连接、版本、连接池状态
状态 get_server_status MySQL 关键指标(QPS、连接数、慢查询、流量)
浏览 list_databases 列出所有数据库(区分系统/用户库)
浏览 list_tables 列出表(引擎、行数、大小、注释)
浏览 describe_table 字段/主键/索引/外键/建表SQL
浏览 list_views 列出视图
浏览 list_routines 存储过程/函数
浏览 list_triggers 触发器
浏览 er_graph 跨表外键关系(nodes+edges,可画ER图)
查询 execute_query 任意SQL(读/写/DDL,安全分级拦截)
查询 execute_select 只读SELECT(额外安全层)
查询 get_table_data 快速取数(分页/排序/条件)
查询 count_rows 行数统计
分析 explain_query EXPLAIN执行计划 + 中文性能解读
导出 export_query 导出CSV(Excel友好BOM)或JSON文件
历史 list_query_history 本会话SQL历史
事务 begin_transaction 开启事务
事务 commit_transaction / rollback_transaction 提交/回滚
监控 show_processlist MySQL进程列表
管理 kill_query Kill长查询

还有 4 个 MCP Prompts 预置模板:generate_query(自然语言→SQL)、optimize_sql(性能优化)、compare_schema(表结构对比)、database_summary(整体概览)。

🔒 安全特性

  • ✅ 只读模式开关(READ_ONLY=true 时禁止一切写/DDL)
  • ✅ DDL 独立开关(默认禁用 CREATE/ALTER/DROP)
  • ✅ 危险语句永远拦截(GRANT/REVOKE/SHUTDOWN/KILL/FLUSH 等)
  • ✅ 参数化查询(%s 占位符,防SQL注入)
  • ✅ 结果集行数上限(默认1000行)
  • ✅ 服务端查询超时(默认30秒强制终止)
  • ✅ 审计日志(所有执行SQL落盘)

🛠 安装步骤

Step 0 — 检查环境

确认本机有 Python 3.10+ 和可用的 MySQL:

python --version   # 需要 3.10+
mysql --version    # 可选,有 MySQL 客户端便于排查

如果没装 Python,去 https://www.python.org/downloads/ 下载安装。

Step 1 — 安装 mysql-mcp-pro 包

pip install mysql-mcp-pro

安装成功后会有命令行工具 mysql-mcp-pro,验证:

mysql-mcp-pro --help
# 看到日志"启动 MySQL MCP Server v2"表示已就绪(stdio模式会等待输入,Ctrl+C退出)

Windows 用户:如果提示命令找不到,检查 Python Scripts 目录是否在 PATH 里,一般在 C:\Users\<你>\AppData\Roaming\Python\Python3xx\Scripts。

Step 2 — 准备 MySQL 连接信息

需要用户提供:

  • MYSQL_HOST(默认 localhost)
  • MYSQL_PORT(默认 3306)
  • MYSQL_USER
  • MYSQL_PASSWORD
  • MYSQL_DATABASE(要连接的默认数据库名,可留空)

安全建议:建议为 MCP 创建专用低权限用户:

CREATE USER 'mcp_user'@'%' IDENTIFIED BY 'strong_password';
GRANT SELECT, INSERT, UPDATE ON your_db.* TO 'mcp_user'@'%';
-- 只读场景只给 SELECT:
-- GRANT SELECT ON your_db.* TO 'mcp_user'@'%';

Step 3 — 注册到 AI 客户端

根据用户的客户端,写入对应的 MCP 配置文件。所有配置都使用 JSON 格式。

WorkBuddy(本平台)

编辑 ~/.workbuddy/mcp.json:

{
  "mcpServers": {
    "mysql": {
      "command": "mysql-mcp-pro",
      "env": {
        "MYSQL_HOST": "localhost",
        "MYSQL_PORT": "3306",
        "MYSQL_USER": "mcp_user",
        "MYSQL_PASSWORD": "your_password",
        "MYSQL_DATABASE": "your_database",
        "READ_ONLY": "false",
        "ALLOW_DDL": "false",
        "MAX_RESULT_ROWS": "1000",
        "QUERY_TIMEOUT": "30"
      }
    }
  }
}

保存后在 WorkBuddy 连接器页面点击刷新(或重启 WorkBuddy),mysql 连接器亮起即成功。

Claude Desktop

  • macOS:~/Library/Application Support/Claude/claude_desktop_config.json
  • Windows:%APPDATA%\Claude\claude_desktop_config.json

格式同上,放在 mcpServers 字段下。保存后重启 Claude Desktop。

Cursor

在项目根目录创建 .cursor/mcp.json,格式同上;或在 Settings → MCP 添加。

Cline / VS Code 其他 MCP 插件

在对应 MCP 设置页面添加 server,command 填 mysql-mcp-pro,env 填连接信息。

Step 4 — 健康检查

配置完成后,在对话里让 AI 执行测试:

"测试一下 MySQL 连接,列出所有数据库"

如果 AI 返回数据库列表,说明配置成功。如果失败,用下方"故障排查"。

⚙️ 环境变量完整清单

变量 默认值 说明
MYSQL_HOST localhost MySQL 主机
MYSQL_PORT 3306 端口
MYSQL_USER root 用户名
MYSQL_PASSWORD (空) 密码
MYSQL_DATABASE (空) 默认数据库
MYSQL_CHARSET utf8mb4 字符集
READ_ONLY false 只读模式
ALLOW_DDL false 允许 DDL
MAX_RESULT_ROWS 1000 查询最大返回行数
QUERY_TIMEOUT 30 查询超时秒数
POOL_SIZE 5 连接池大小
AUDIT_LOG true 审计日志开关
EXPORT_DIR ./exports CSV/JSON导出目录
MCP_TRANSPORT stdio 传输模式:stdio/sse/streamable-http
MCP_HOST 127.0.0.1 HTTP 监听地址
MCP_PORT 8000 HTTP 端口

🔧 故障排查

连接被拒绝 / Can't connect to MySQL server

  • 检查 MySQL 是否启动:netstat -an | findstr 3306(Windows)或 ss -tlnp | grep 3306(macOS/Linux)
  • 检查 host/port 是否正确
  • 如果 MySQL 在 Docker 里,确认端口已映射到宿主机

Access denied for user

  • 用户名/密码错误,注意大小写和特殊字符
  • 用户是否允许从 localhost 连接(MySQL 用户是 user@host 绑定的)
  • Windows 下密码含 ! 等特殊字符时,在 JSON 里直接写原文即可(JSON 字符串不需要转义 !)

MCP 工具没出现在 AI 里

  1. 确认 mysql-mcp-pro 命令可直接在终端运行(无报错)
  2. 检查 MCP 配置文件 JSON 语法正确(没有尾逗号、引号成对)
  3. 完全重启客户端(不是刷新页面)
  4. 查看客户端的 MCP 日志(通常在 View → Toggle Developer Tools 里)

bash: mysql-mcp-pro: command not found

  • Python Scripts 目录不在 PATH,用绝对路径:
    • Windows: C:\Users\<你>\AppData\Roaming\Python\Python3xx\Scripts\mysql-mcp-pro.exe
    • macOS/Linux: ~/Library/Python/3.x/bin/mysql-mcp-pro 或 ~/.local/bin/mysql-mcp-pro
  • 或在配置里用 python -m 方式启动(不推荐,需指定 server.py 路径)

查询返回空 / 奇怪错误

  • 检查 MYSQL_DATABASE 是否正确设置,或在 SQL 里用 USE dbname;
  • 先调用 ping 工具确认当前默认库

想清空所有配置重来

  • 删除 MCP 配置文件里的 mysql 条目,重启客户端
  • 删除 exports/ 目录里的历史文件(可选)

📚 参考资料

🧪 快速验证脚本(可选)

skill 自带 scripts/healthcheck.py,装好包后可跑一下确认环境 OK:

python scripts/healthcheck.py

📝 使用建议

  1. 首次使用:先让 AI 执行 database_summary 提示词("给我做一份数据库概览"),AI 会自动调用多个工具了解库结构
  2. 写操作前:先用 SELECT 确认 WHERE 条件命中的数据,再执行 UPDATE/DELETE
  3. 批量操作:用 begin_transaction 包起来,确认无误再 commit_transaction,否则 rollback_transaction
  4. 慢查询:把 SQL 丢给 explain_query,它会提示是否有全表扫描/filesort/索引问题
  5. 导出报表:export_query 直接导出 CSV,用 Excel 打开不会乱码(UTF-8 BOM)
  6. 生产环境:强烈建议开启 READ_ONLY=true,AI 只能查不能改

更新

升级到最新版:

pip install --upgrade mysql-mcp-pro

重启 AI 客户端即可生效。

Current listing version

2.0.1

Verify the source revision ↗

Safety and assessment details

Quality assessment

Out of 100 · Assessment report from SkillPi LAB.

Scenario Value95/100

Highlights

  • 提供 25 个专业数据库工具,覆盖连接、查询、分析、导出、事务等完整数据库操作场景
  • 内置生产级安全机制(连接池、防注入、危险语句拦截、审计日志)
  • 直接解决数据库管理与数据分析的高频刚需任务
Trigger Precision90/100

Highlights

  • 触发场景描述清晰完整,涵盖连接、查询、结构查看、性能分析、数据导出等典型用例
  • 边界明确,不易与其他 Skill 混淆
Structure and Standards90/100

Highlights

  • 文档结构完整,包含使用场景、工具列表、安装步骤、配置说明、故障排查等必要章节
  • 提供详细的配置示例和环境变量说明,便于用户快速上手
Execution Reliability85/100

Highlights

  • 提供完整的安装命令和配置模板,工具来源明确(PyPI 包)
  • 覆盖常见故障场景并提供排查方案,提升执行成功率
Evidence Verifiability (mean of the first four)90/100

The arithmetic mean of the first four original scores, rounded to a whole number.

Static text checks

100 / 100 · skillpi-20261123-no-r3-v1

No current rules matched the text.

This score reflects rule matches in the text and is provided for reference before use. It excludes attachments and runtime behavior.

Permissions and checks before use

Automatically summarized from this main document. Matches may be examples or defensive advice; they are not actual permission declarations. Attachments, external dependencies and runtime behavior are not covered.

  • Install or fetch external dependencies

    Use official sources and pin versions. Check install scripts in an isolated environment. This document check does not cover code downloaded later.

    Mentioned in main document · lines 94, 251
Domains or addresses referenced in the document

These addresses may be documentation links or examples, not an approved network allowlist. Verify actual destinations and outgoing data before use.

  • dev.mysql.com
  • github.com
  • modelcontextprotocol.io
  • pypi.org
  • www.python.org

These notices grant no permissions. Your host tool must still confirm file changes, secrets, external transfers or costs as needed.

Security rating and access scope

safe · Static evidence review; not a runtime safety guarantee.

Translation pending; see source documentation.

Before use, confirm and authorize actual file access, external services and network destinations in your host. This review grants no runtime permissions.