---
title: "Connect MySQL to Rig — Rig guide"
description: "Connect a MySQL database to Rig with a read-only user, then sync its tables into your warehouse on a schedule."
canonical: "https://rig.so/guides/connect-mysql"
format: markdown
---

Search guides, references, playbooks…⌘K

Browse guides

# Connect MySQL to Rig

Rig Ingest copies the tables you choose from a MySQL database into your warehouse, so reporting queries run there and the application database stays quiet. It connects with a host, a database name and a user that can only read.

## Before you start

- You need the host, port and database name of the MySQL server, and a network path from Rig to it. If a firewall protects the server, it has to let Rig in. [Contact us](https://rig.so/contact) for the addresses to allow.
- You need an account on the server that is allowed to create users and grant privileges, such as an admin account.
- Decide which database holds the tables you want. The database name is required; the schema is optional.

## Step 1: Create a read-only MySQL user

A new account has no privileges until you grant them, so the user can only do what you allow. Give it read access to one database and nothing else.

1. Connect to the server as an account that can create users.
2. Create the user with `CREATE USER 'rig_reader'@'%' IDENTIFIED BY 'a-strong-password';`. Use a host pattern that matches where Rig connects from if you want to narrow it.
3. Grant read access with `GRANT SELECT ON your_database.* TO 'rig_reader'@'%';`. Replace `your_database` with the database you want Rig to read.
4. Keep the user name and password. You enter them in Rig in the last step.

Keep the grant narrow
SELECT on one database is enough to read tables. MySQL adds privileges together across levels, so do not also grant anything globally.

## Step 2: Connect it in Rig

New to Rig? Watch how to find Connections

Adding a source needs a workspace owner, or a role with the Manage connections permission, on a workspace where you manage your own connections. If the Connectors tab says “Data ingestion for this workspace is managed by Rig”, ask an owner or Rig support to add the source.

1. In Rig, open `Connections`, choose the `Connectors` tab and go to `Sources & actions`.
2. Search for **MySQL**, open the card and click `Connect`.
3. **Dialect**: Leave it as `mysql+pymysql`.
4. **Host**: The server's host name or IP address.
5. **Port**: Leave it at `3306` unless your server listens on another port.
6. **Database name**: The database that holds your tables.
7. **Username**: The read-only user you created, such as `rig_reader`.
8. **Password**: That user's password.
9. **Schema**: Optional. Fill it in only if you want to limit the sync to one schema.
10. Click `Continue`. Rig checks the credentials and lists the streams it can reach, so choose the ones you want and click `Connect`.
11. The source then syncs on its schedule, which is nightly unless you change it. To load data straight away, click `Sync` on its row; `Test` pulls a small sample first if you want to check the connection.

## What Rig pulls in

MySQL lands in its own `mysql` schema in your warehouse:

- **Tables**: the tables Rig can reach in the database. After you click Continue, Rig lists them and you choose which to sync.
- **Table structure**: column names and types, so Rig can describe each table when you ask questions about it.

The tables come from your own database, so their names and columns match what you have there.

## Good to know

- Tables that sync incrementally of up to 5,000,000 rows are re-read in full once a week so Rig can notice rows you deleted. That adds read load to your database for a short time. Larger tables, and tables MySQL cannot estimate the size of, are not re-read, so deletions in those are not tracked.
- You can add more than one MySQL database as separate sources, each with its own user.
- Amazon Aurora and PlanetScale use the same MySQL protocol, so the same fields apply.
- To disconnect MySQL, click the bin icon on the source's row under `Sources & actions`. Only whoever connected the source or a workspace owner can do this, and data already synced stays in the warehouse.

## What people use this for

- Query MySQL data without writing SQL
- Replicate MySQL into your warehouse
- Work with Aurora and PlanetScale the same way
- Ask MySQL questions in Claude, Cursor or ChatGPT

[More ideas for using MySQL](https://rig.so/integrations/mysql)

## MySQL documentation

- [MySQL 8.4: CREATE USER statement](https://dev.mysql.com/doc/refman/8.4/en/create-user.html)
- [MySQL: GRANT statement](https://dev.mysql.com/doc/en/grant.html)

Was this guide helpful?

Yes No

---

- [This page as HTML](https://rig.so/guides/connect-mysql)
- [Site map for language models](https://rig.so/llms.txt)
- [API and agent documentation](https://rig.so/developers)
