Step‑by‑Step Guide to Install and Use MCP MySQL Server with Cursor
This guide walks through installing the MCP MySQL server npm package, using its five command‑line tools, testing with the Inspector client, configuring the Cursor environment via JSON, restarting Cursor, and executing basic SQL commands through the @mysql‑local interface.
1. Install MCP MySQL Server Package
Use npm to install the MCP MySQL server globally: npm install -g @f4ww4z/mcp-mysql-server The package provides five command‑line utilities:
connect_db – connect to the database
query – execute SELECT queries
execute – run INSERT/UPDATE/DELETE statements
list_tables – list all tables
describe_table – show table structure
2. Test MCP MySQL Server with Inspector (Optional)
Install the Inspector client, which can be used to test the MCP tools: npm install -g @modelcontextprotocol/inspector Run the inspector, which automatically opens a browser UI:
npx @modelcontextprotocol/inspector npx @f4ww4z/mcp-mysql-server --host 127.0.0.1 --port 3306 --user root --password 1234563. Configure MCP in Cursor
Add a custom MCP server definition to the Cursor configuration (e.g., mcp.json) using the name mysql-local:
{
"mcpServers": {
"mysql-local": {
"command": "npx",
"args": ["-y", "@f4ww4z/mcp-mysql-server"],
"env": {
"MYSQL_HOST": "127.0.0.1",
"MYSQL_USER": "root",
"MYSQL_PASSWORD": "123456",
"MYSQL_DATABASE": "test"
}
}
}
}After saving, a green dot indicates the configuration is active.
4. Restart Cursor
Restart the Cursor application so it can recognize the newly added mysql-local MCP server.
5. Usage
Execute SQL statements through the @mysql-local command interface:
@mysql-local execute: SELECT 1 as test_connection; @mysql-local execute: SELECT * FROM xxxx LIMIT 5; @mysql-local execute: SHOW CREATE TABLE xxxx;These steps demonstrate how to set up the MCP MySQL server, verify it with Inspector, integrate it into Cursor, and run basic database commands.
AI Software Product Manager
Daily updates of Xiaomi's latest AI internal materials
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
