Connect ChatGPT to MySQL, read-only

Add your MySQL database to AI2SQL, install the AI2SQL app in ChatGPT and sign in. ChatGPT can then answer questions from your MySQL data with real SQL, while writes are blocked and your password never leaves AI2SQL.

Short answer: ChatGPT can't open a connection to MySQL by itself. Give it one through an app that only runs read-only SQL. With AI2SQL you add the database once with a SELECT-only user, install the AI2SQL app in ChatGPT, and sign in. The same steps work for Amazon RDS, Aurora MySQL, PlanetScale and MariaDB.

Step 1: a read-only MySQL user

Enforce read-only in MySQL itself, so a write fails even if every other layer missed it:

CREATE USER 'chatgpt_ro'@'%' IDENTIFIED BY 'a-long-random-password';
GRANT SELECT, SHOW VIEW ON appdb.* TO 'chatgpt_ro'@'%';
FLUSH PRIVILEGES;

To keep some tables out of reach, grant SELECT on chosen tables (GRANT SELECT ON appdb.orders TO ...) instead of the whole database. Replace % with AI2SQL's address range if your server restricts hosts.

Step 2: add the database to AI2SQL

Sign in at builder.ai2sql.io, open Connections, pick MySQL and enter the host, port (usually 3306), database and the chatgpt_ro user. If MySQL runs on your laptop (XAMPP, MAMP, Docker) or inside a private network, use the desktop connector instead.

Step 3: install AI2SQL in ChatGPT

  1. Open the AI2SQL app in the ChatGPT plugin directory and add it.
  2. ChatGPT opens AI2SQL. Sign in with the account that holds the MySQL connection and press Allow.
  3. In a new chat, type @AI2SQL so ChatGPT uses the app for your question.

Prefer to add it by hand? Turn on developer mode in ChatGPT's connector settings and create a connector with the URL https://builder.ai2sql.io/api/chatgpt-mcp and OAuth authentication.

Step 4: ask a question

Try "@AI2SQL describe my MySQL database, then show the 10 best-selling products this month." ChatGPT reads the real schema with describe_schema, writes MySQL SQL (DATE_FORMAT, LIMIT, backtick names) and runs it with run_query. Ask ChatGPT to show the SQL it ran if you want to check it.

What keeps it safe

Common MySQL snags

The same connection also works from Claude. For PostgreSQL and SQL Server, see ChatGPT + PostgreSQL and ChatGPT + SQL Server.

Frequently asked

Can ChatGPT connect to a MySQL database? +

Yes. Install the AI2SQL app in ChatGPT and sign in. Once a MySQL connection is added in AI2SQL, ChatGPT can read its schema and run read-only queries on it. ChatGPT never sees the database password.

Can ChatGPT change data in MySQL? +

Not through AI2SQL. Each call accepts one SELECT or WITH statement. INSERT, UPDATE, DELETE, REPLACE, DDL, SELECT ... INTO OUTFILE and functions such as LOAD_FILE, SLEEP and BENCHMARK are rejected before they reach MySQL. A SELECT-only user makes the database refuse writes as well.

Does it work with Amazon RDS, Aurora MySQL, PlanetScale or MariaDB? +

Any MySQL-compatible server that AI2SQL can reach over the network works the same way. A MySQL on localhost, XAMPP or a private network needs the AI2SQL desktop connector instead.

Do I need ChatGPT developer mode? +

No. AI2SQL is in the ChatGPT plugin directory. Developer mode is only needed if you want to add the server URL by hand.

Can I try it before connecting my database? +

Yes. Ask: Use AI2SQL to show the top 5 customers by revenue in demo_shop. demo_shop is a shared sample store with fake data and works on every plan. Running queries on your own database needs Pro or Team, which start with a 7-day trial.

Ask ChatGPT about your MySQL data

Connect MySQL, add the AI2SQL app in ChatGPT, sign in. Read-only and logged from the first query.

Connect MySQL free →

Related guides