Connect Cursor to MySQL with MCP
Connect Cursor to a MySQL database over MCP with a local DBHub server or with Contextflo. Includes the read-only user SQL and mcp.json config for both options.
Jump to a section
To query MySQL from Cursor, run a local MCP server such as DBHub, or connect MySQL to Contextflo once and share it with your team. The local route takes a minute. The Contextflo route keeps the password off every laptop.
Option 1: DBHub in Cursor
@bytebase/dbhub supports MySQL and runs over stdio with npx. Create a read-only user first, and point DBHub at a replica:
Loading code sample...
Then add it to ~/.cursor/mcp.json (global) or .cursor/mcp.json (this repo):
Loading code sample...
Check the DBHub README for the exact flags in your version. Cursor lists the server in its MCP settings, where you can toggle it.
Option 2: Contextflo
Use the same read-only user. In Contextflo, go to Data Sources, then Add data source:
| Field | Value |
|---|---|
| Host | Your MySQL host |
| Port | Your MySQL port |
| Username | contextflo_ro |
| Password | The password you set |
SSL is on by default, and an SSH bastion is optional. Pick the tables to expose and invite your team. Then add Contextflo to Cursor:
Loading code sample...
Cursor opens the OAuth sign-in. Contextflo runs SELECT only, and the MySQL user is read-only too.
Contextflo generates table and column descriptions. Your team saves definitions as shared context. Each person sees only their tables. The audit trail records prompts and the SQL that ran, and a weekly digest summarizes it.
Which one to use
Just you, one database, a repo open in Cursor? DBHub is enough. If your team asks too, use Contextflo: shared context, per-person table access, and an audit trail of prompts and the SQL that ran.
You do the modeling, we do the rest. Connect MySQL free.
FAQ
Which MCP server works with MySQL in Cursor?
@bytebase/dbhub supports MySQL and runs over stdio with npx, so it fits Cursor's command and args config. Point it at a replica.
Should Cursor connect to my primary MySQL database?
Use a replica and a read-only user. That keeps an exploratory query away from your production writes.
Does Contextflo use SSL with MySQL?
SSL is on by default. You can also route through an SSH bastion if the database is not publicly reachable.
Where do I put the MySQL password in Cursor?
In the connection string inside mcp.json. Keep a project-level .cursor/mcp.json out of version control, or use Contextflo so the credentials stay out of every laptop.