New teams get free Claude credits for their trial. Learn more

Connect Cursor to MySQL with MCP

October 22, 2026•4 min read•Vivek Sah
Connect Cursor to MySQL with MCP

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:

CREATE USER 'contextflo_ro'@'%' IDENTIFIED BY '<password>';
GRANT SELECT ON mydb.* TO 'contextflo_ro'@'%';

Then add it to ~/.cursor/mcp.json (global) or .cursor/mcp.json (this repo):

{
  "mcpServers": {
    "mysql": {
      "command": "npx",
      "args": [
        "-y",
        "@bytebase/dbhub",
        "--dsn",
        "mysql://contextflo_ro:<password>@replica-host:3306/mydb"
      ]
    }
  }
}

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:

FieldValue
HostYour MySQL host
PortYour MySQL port
Usernamecontextflo_ro
PasswordThe 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:

{
  "mcpServers": {
    "contextflo": {
      "url": "https://mcp.contextflo.com/mcp"
    }
  }
}

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.