Give Codex read-only access to MySQL
Connect Codex to MySQL over MCP. Run @bytebase/dbhub from config.toml against a replica, or use Contextflo with a read-only user and a per-person audit trail.
Jump to a section
Codex can query MySQL from the terminal. Run a local MCP server such as dbhub against a replica, or connect MySQL to Contextflo once and give Codex a single URL. Create a read-only user before either.
Option 1: dbhub in Codex
@bytebase/dbhub supports MySQL. It runs as a local stdio server through npx and takes a DSN for your database. Point the DSN at a replica, and use a read-only user.
In ~/.codex/config.toml:
Loading code sample...
Add your DSN to args as the dbhub README describes. Credentials sit in your own config file, on your own machine. Nothing is shared with teammates.
Option 2: Contextflo
Create a read-only user:
Loading code sample...
In Contextflo, go to Data Sources, then Add data source, and choose MySQL. Enter host, port, username and password. SSL is on by default, and an SSH bastion is optional. Pick tables and invite your team.
In Codex:
Loading code sample...
Loading code sample...
codex mcp list shows the connection. Contextflo runs SELECT only.
Which one to use
Just you, on your own replica: Option 1.
Your team asks too: Contextflo. Table and column descriptions are generated, your team saves shared definitions, each person gets their own table access, and you get 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 Codex?
@bytebase/dbhub supports MySQL and runs over stdio with npx and a DSN. Add it as a [mcp_servers.name] table in ~/.codex/config.toml.
Should Codex connect to my primary MySQL database?
Point it at a replica. Agents can write heavy queries, and a replica keeps them off the primary. Add a read-only user on top.
Does Contextflo use SSL to connect to MySQL?
SSL is on by default. An SSH bastion is available as an option for databases that are not publicly reachable.
What does the MySQL grant for Contextflo cover?
SELECT on one database, for example mydb.*. The user cannot insert, update or delete.