MCP MySQL Server
Connects to MySQL databases and executes SELECT queries for read-only data access, with support for querying tables, filtering data, and performing aggregations.
Click on "Install Server".
Wait a few minutes for the server to deploy. Once ready, it will show a "Started" state.
In the chat, type
@followed by the MCP server name and your instructions, e.g., "@MCP MySQL Servershow me the top 10 customers by total purchase amount"
That's it! The server will respond to your query, and you can continue using it as needed.
Here is a step-by-step guide with screenshots.
MCP MySQL Server
一个用于连接和查询MySQL数据库的MCP (Model Context Protocol) 服务器。
功能特性
通过 SSE (Server-Sent Events) 提供 HTTP 接口
连接MySQL数据库
执行 SELECT 查询(只读访问)
安全的只读模式,不支持 INSERT/UPDATE/DELETE 操作
Related MCP server: MySQL MCP Server
安装
使用 uv(推荐)
# 安装 uv(如果尚未安装)
pip install uv
# 创建虚拟环境
uv venv
# 激活虚拟环境
.venv\Scripts\activate # Windows
# source .venv/bin/activate # MacOS/Linux
# 安装项目
pip install -e .使用 pip
# 创建虚拟环境
python -m venv venv
.\venv\Scripts\activate # Windows
# source venv/bin/activate # MacOS/Linux
# 安装项目
pip install -e .使用方法
启动服务器
# 设置环境变量
export MYSQL_HOST=localhost
export MYSQL_PORT=3306
export MYSQL_USER=your_username
export MYSQL_PASSWORD=your_password
export MYSQL_DATABASE=your_database
export QUERY_TIMEOUT=30 # 查询超时时间(秒)
# Windows PowerShell
$env:MYSQL_HOST="localhost"
$env:MYSQL_PORT="3306"
$env:MYSQL_USER="your_username"
$env:MYSQL_PASSWORD="your_password"
$env:MYSQL_DATABASE="your_database"
$env:QUERY_TIMEOUT="30" # 查询超时时间(秒)
# 启动 SSE 服务器
python -m mcp_mysql.server
# 或
mcp-mysql
# 服务器将运行在 http://localhost:8000配置参数
环境变量:
MYSQL_HOST- MySQL 服务器地址(默认: localhost)MYSQL_PORT- MySQL 端口(默认: 3306)MYSQL_USER- 数据库用户名(默认: root)MYSQL_PASSWORD- 数据库密码(默认: 空)MYSQL_DATABASE- 数据库名称(默认: 空)QUERY_TIMEOUT- 查询超时时间,单位秒(默认: 30)MCP_HOST- MCP 服务器地址(默认: 0.0.0.0)MCP_PORT- MCP 服务器端口(默认: 8000)
在 Claude Desktop 中配置
在 Claude Desktop 配置文件中添加以下配置:
MacOS: ~/Library/Application Support/Claude/claude_desktop_config.json
Windows: %APPDATA%\Claude\claude_desktop_config.json
{
"mcpServers": {
"mysql": {
"url": "http://localhost:8000/sse"
}
}
}可用工具
query - 执行 SELECT 查询
sql: 要执行的 SELECT 语句(仅支持 SELECT 查询,保证只读访问)
示例
连接后,你可以:
"查询 users 表的所有数据:SELECT * FROM users"
"查询特定条件:SELECT name, email FROM users WHERE id > 10"
"统计数据:SELECT COUNT(*) FROM orders WHERE status='completed'"
注意: 为了数据安全,本服务器只支持 SELECT 查询,不支持 INSERT、UPDATE、DELETE 等写操作。
安全注意事项
请妥善保管数据库凭据
建议使用只读账户
不要在公共仓库中提交包含密码的配置文件
This server cannot be installed
Maintenance
Resources
Unclaimed servers have limited discoverability.
Looking for Admin?
If you are the server author, to access and configure the admin panel.
Related MCP Servers
- AlicenseBqualityDmaintenanceProvides secure, read-only access to MariaDB/MySQL databases, allowing users to list databases, explore table schemas, and execute SQL queries with built-in security measures.Last updated4544MIT
- Alicense-qualityDmaintenanceProvides read-only access to MySQL databases with automatic schema discovery and secure query execution. Enables users to explore database structure and execute SELECT queries through natural language interactions.Last updatedMIT
- Flicense-qualityDmaintenanceEnables safe interaction with MySQL databases through SELECT queries, table structure inspection, and database schema exploration. Provides read-only access to query data and examine database metadata.Last updated1
- AlicenseAqualityDmaintenanceEnables read-only MySQL database access, allowing listing databases, tables, describing schemas, and executing SELECT/SHOW/DESCRIBE/EXPLAIN queries.Last updated7424MIT
Related MCP Connectors
Query PostgreSQL databases in plain English — LLM-generated, safety-validated SQL.
The stock market, in SQL — scan, replay, or subscribe across ~12k US tickers and top 100 cryptos.
Read-only access to your VortexIQ store data: audits, KPIs, alerts, Brand DNA, reports, Ask VIQ.
Latest Blog Posts
- Who's Calling? MCP Hosts Are an Identity Blind Spot (And the Spec Knows It)By Om-Shree-0709 on .mcpAgent IdentityOAuth 2.1
- Your AI Chatbot Just Exposed Your CEO's Salary to an InternBy Om-Shree-0709 on .Agent IdentityMCP SecurityOAuth Delegation
- Why MCP Servers Need Execution Sandboxing (And Why Your Current Stack Isn't Enough)By Om-Shree-0709 on .Agentic AiPrompt InjectionWebAssembly
MCP directory API
We provide all the information about MCP servers via our MCP API.
curl -X GET 'https://glama.ai/api/mcp/v1/servers/coderleo/mcp_mysql'
If you have feedback or need assistance with the MCP directory API, please join our Discord server