A MCP MySQL server with DDL support, permission control and operation logs.
Version History
v3.2.0 (Latest)
✅ Readonly Hardening: Validate complete statements and use read-only transactions to block write-through SELECT queries and unsafe SQL forms.
MCP MySQL server with DDL support, permission control and operation logs
2026-11-16
स्टार
—
टूल
—
अपटाइम
—
✅ Optional TLS: MYSQL_SSL=true enables certificate and hostname verification without forcing TLS on existing non-TLS connections.
✅ Connection Configuration: Replace unsupported timeout options with connectTimeout; initial and replacement pools share the same settings.
✅ Regression Coverage: Add SQL policy, connection lifecycle, TLS configuration and version consistency tests.
v3.1.1
✅ Claude Skill Support: Added SKILL.md for Claude integration.
v3.1.0
✅ BIGINT Precision Support: Added supportBigNumbers and bigNumberStrings options to prevent precision loss for large integers (e.g., order_id, user_id > 2^53 - 1). Values are returned as strings to maintain full precision.
v3.0.0
✅ Readonly Mode: Added READONLY environment variable - when enabled, only SELECT and SHOW commands are allowed (highest priority check)
✅ Tool Prefix Support: Added TOOL_PREFIX environment variable for tool name isolation and config separation
Only MYSQL_SSL=true enables TLS. Leaving it unset or setting it to false preserves non-TLS connections. The same setting applies when the pool is initialized or rebuilt; an enabled TLS connection never retries without TLS after a handshake or certificate failure.
TLS verifies the certificate chain and server hostname. Use the database DNS name matching its certificate as MYSQL_HOST. For a private or self-signed CA, set NODE_EXTRA_CA_CERTS=/absolute/path/to/ca.pem in the MCP process environment before starting Node.js and restart the service. CLI and managed launches inherit these environment variables. Do not disable certificate validation to work around trust errors.
Usage
1. Direct Run (Global Installation)
mcp-server-mysql
2. Using npx (Recommended)
npx @liangshanli/mcp-server-mysql
3. Direct Start (Source Installation)
npm start
4. Managed Start (Recommended for Production)
npm run start-managed
Managed start provides:
Auto-restart (up to 10 times)
Error recovery
Process management
Logging
5. Development Mode
npm run dev
Editor Integration
Cursor Editor Configuration
Create .cursor/mcp.json file in your project root:
You can configure multiple MySQL server instances with different TOOL_PREFIX and PROJECT_NAME to isolate tools and configurations. This is useful when you need to connect to multiple databases simultaneously.
READONLY=true takes priority over every ALLOW_* flag. Readonly requests accept only a single SELECT or SHOW and execute inside START TRANSACTION READ ONLY on the same connection. The transaction is rolled back after success or failure. If transaction setup fails, client SQL is not executed; a connection whose rollback fails is destroyed instead of returned to the pool.
All modes explicitly disable multiple statements and validate the entire SQL before database access. One trailing semicolon is allowed; semicolons inside quoted text or ordinary comments are not statement separators.
MySQL /*! ... */ and MariaDB /*M! ... */ executable comments are rejected. Ordinary leading comments cannot bypass DDL, DROP or DELETE checks.
Readonly mode rejects SELECT ... INTO OUTFILE/DUMPFILE, INTO @variable, := assignments, FOR UPDATE/SHARE, LOCK IN SHARE MODE, and functions that acquire or release advisory locks.
Quote and backslash interpretation varies with sql_mode; input that cannot be validated safely under all supported interpretations is rejected conservatively. Readonly mode still rejects commands starting with WITH, EXPLAIN, CALL, or other non-allowlisted commands.
Single-statement validation conservatively rejects compound scripts such as stored routine definitions containing internal semicolons. Use a separate controlled migration tool for those scripts.
Application checks do not replace database privileges. Read-only transactions additionally guard against stored functions modifying regular tables, but are not a complete sandbox for arbitrary UDFs, external side effects, or temporary-table operations. In production, use a dedicated least-privilege account with only the required query and metadata privileges, without write, DDL, FILE, or unnecessary EXECUTE privileges. Do not use root for readonly access.
Restart the actual MCP service after updating. Running npx @liangshanli/mcp-server-mysql does not automatically use local source changes; point the client at the local bin/cli.js or install a version containing the fix.
Connection Pool Features
Auto-creation: Automatically creates connection pool on notifications/initialized
Health checks: Checks connection pool status every 5 minutes
Auto-reconnection: Automatically recreates connection pool when it fails
Connection reuse: Uses connection pool for better performance
Graceful shutdown: Properly releases connections when server shuts down
Logging
General Logs
Log file location: ./.setting/mcp-mysql.log (or ./.setting.<TOOL_PREFIX>/mcp-mysql.log if TOOL_PREFIX is set)
Logged content:
All requests and responses
SQL operation records
Error messages
Connection pool status changes
DDL SQL Logs (v2.0.1+)
DDL log file location: ./.setting/ddl.sql (or ./.setting.<TOOL_PREFIX>/ddl.sql if TOOL_PREFIX is set)
Features:
Success-Only Recording: Only successful DDL operations are recorded
Timestamped Entries: Each operation includes precise timestamp comments
Auto-Formatting: SQL statements are automatically formatted with semicolon endings
Executable Format: Can be directly executed to recreate database structure
Example DDL log format:
# 2024-01-15 14:23:45
CREATE TABLE users (id INT PRIMARY KEY, name VARCHAR(100));
# 2024-01-15 14:24:12
ALTER TABLE users ADD COLUMN email VARCHAR(255);
# 2024-01-15 14:25:33
CREATE INDEX idx_email ON users(email);
DDL Logging Benefits
🔄 Database Synchronization
Production Sync: Easily synchronize database schema changes from development to production environments
Multi-Environment Deployment: Apply the same DDL changes across staging, testing, and production databases
Rollback Support: Maintain a complete history of schema changes for easy rollback operations
📋 Development Workflow
Schema Versioning: Track database evolution with timestamped change history
Team Collaboration: Share database structure changes with team members through executable SQL files
अभी टूल सूची नहीं है। रिमोट सर्वर को पहले हेल्थ चेक के बाद सूची मिलती है।
FAQ
सवाल
@liangshanli/mcp Server Mysql कैसे इंस्टॉल करें?
इस पेज पर Cursor, Claude Desktop, Claude Code या VS Code के लिए stdio कॉन्फ़िग कॉपी करें। यह पब्लिशर का इंस्टॉल इस्तेमाल करता है, PlugMCP प्रॉक्सी नहीं।
क्या @liangshanli/mcp Server Mysql के लिए API key चाहिए?
इस रिकॉर्ड में कोई ज़रूरी एनवायरनमेंट वेरिएबल दर्ज नहीं है।
@liangshanli/mcp Server Mysql कौन सा ट्रांसपोर्ट इस्तेमाल करता है?
@liangshanli/mcp Server Mysql stdio पर लोकल चलता है।
@liangshanli/mcp Server Mysql की पिछली जाँच कब हुई थी?
पिछली जाँच 2026-11-16 को हुई। MCP MySQL server with DDL support, permission control and operation logs