The OpenAI Codex CLI is a developer tool that brings AI assistance directly into your terminal. Connect it to your MySQL database through Sequel's MCP server and you can ask natural language questions about your data from the same terminal where you write code. No SQL client, no context switching.
What You'll Accomplish
After this setup, you can run the Codex CLI and ask:
- "What's the structure of the users table?"
- "How many orders are in 'pending' status right now?"
- "Which customers placed more than 5 orders in the past month?"
Prerequisites
- A Sequel account: Sign up free at sequel.sh
- A running MySQL database: local or cloud-hosted
- OpenAI Codex CLI installed: follow the install guide at openai.com/codex
Step 1: Connect Your MySQL Database to Sequel
Sign in to sequel.sh and click Data Sources in the left sidebar.

Click New Connection. On the "Choose a connector" page, select MySQL.

Fill in two fields:
- Connection Name: a memorable label, e.g.
My App MySQL - Connection String: your full MySQL connection string:
mysql://username:password@host:3306/database_name

Click Connect to verify and save.
Recommended: Create a read-only MySQL user before connecting:
CREATE USER 'sequel_reader'@'%' IDENTIFIED BY 'strong_password'; GRANT SELECT ON your_database.* TO 'sequel_reader'@'%'; FLUSH PRIVILEGES;
Step 2: Get Your Sequel API Key
Click Settings in the left sidebar, then select API Keys from the settings navigation.

Click New key, name it codex-mysql, and copy the key (starts with sql_).
Step 3: Configure Codex CLI to Use Sequel MCP
Set your API key as an environment variable. Add it to ~/.zshrc or ~/.bashrc:
export SEQUEL_API_KEY="sql_your_api_key"
Reload your shell:
source ~/.zshrc
Add Sequel to ~/.codex/config.toml. Create the file if it doesn't exist:
[mcp_servers.sequel]
url = "https://api.sequel.sh/mcp"
bearer_token_env_var = "SEQUEL_API_KEY"
Save the file and start a new Codex session.
Step 4: Query Your MySQL Database
codex
Then ask:
What tables are in the MySQL database?
Show me today's orders with their totals and customer names.
Are there any users who have never placed an order?
What You Can Do Now
- Explore a new codebase: ask "What are all the tables?" to quickly understand a project's data model
- Debug data during development: ask "Are there any constraint violations in the current dataset?"
- Write better migrations: describe the change you need, ask Codex to check existing rows against the new constraint
- Catch issues before production: ask "Are there any orders with negative total values?" as a pre-deploy check

