> AI agents: this is one page from Mammoth Analytics documentation. The index of all pages as Markdown is https://docs.mammoth.io/llms.txt. Append `.md` to any docs URL, or send `Accept: text/markdown`, to get Markdown.

# MySQL connector

> Connect Mammoth to MySQL: what you need, how to enter credentials, and how to import a table or custom SQL query as a dataset.

The MySQL connector imports data from your MySQL database into Mammoth as a dataset. Import entire tables or write custom SQL queries to select specific rows, columns, or joined data. Mammoth offers AI-assisted query generation when it is enabled for your workspace, and you can refresh the dataset manually or on a schedule.

## Before you start

You need:

- A MySQL server accessible from the internet
- A database user with `SELECT` permission on the tables you want to import
- Your server's hostname or IP address, port (default: 3306), database name, username, and password
- Mammoth's IP address added to your MySQL firewall allowlist—see [Network requirements](https://docs.mammoth.io/learn/connectors/network-requirements/)

## Step 1: Select the MySQL connector

1. In Mammoth, go to **Data Library** and click **+ New Dataset**
2. Select **Connectors**
3. Search for **MySQL**
4. Click the **MySQL** tile

## Step 2: Create a connection

Click **New Connection** to open the credential form.

![MySQL New Connection form with Host URL, Port, Username, Password, Database, and Display Name fields](https://docs.mammoth.io/api/v1/images/20260615_101313_Screenshot2026-05-211600381.jpg)

| Field | Description | Example |
| --- | --- | --- |
| **Host URL** | Hostname or IP address of your MySQL server | `mysql.example.com` |
| **Port** | TCP port MySQL listens on | `3306` (default) |
| **Username** | Database user with SELECT access | `mammoth_reader` |
| **Password** | Password for the database user |—|
| **Database** | Name of the database to connect to | `ecommerce_db` |
| **Display Name** | Optional label for this connection in Mammoth | `MySQL Production` |

**Tip:** Mammoth needs network access\
Your MySQL server must allow inbound connections from Mammoth's IP address, which the connection form shows. See [Network requirements](https://docs.mammoth.io/learn/connectors/network-requirements/) for configuration steps, including the user setup needed for external access.

After filling in the fields, click **Connect**. Mammoth validates the credentials and saves the connection; if validation fails, the error message appears at the bottom of the form.

![MySQL Existing Connections list showing one saved connection and the New Connection button](https://docs.mammoth.io/api/v1/images/20260615_101412_Screenshot2026-05-211552341.jpg)

## Step 3: Select a table and query your data

After you connect, select the connection under **Existing Connections** to open the query builder. The **List of tables** panel shows all tables in your database. Click a table name to load a `SELECT *` query for it and its preview.

To write a custom query, edit the SQL in the **Enter SQL query** editor. MySQL uses backtick quoting for identifiers:

```sql
SELECT `order_id`, `customer_id`, `total_amount`, `created_at`
FROM `orders`
WHERE `created_at` >= DATE_SUB(NOW(), INTERVAL 90 DAY)
  AND `status` = 'shipped'
```

Click **Run** to preview results.

### AI query generation

When enabled for your workspace, the **Describe the data you need...** box appears above the query editor. Use it to tell Mammoth what you want in plain language—for example, *"all shipped orders in the last 90 days with customer IDs"*—and click the generate button. Mammoth writes the SQL query based on your table structure and description. The box is disabled while Mammoth sets up metadata for AI query.

![Edit query dialog with table list, AI description box, SQL editor, Run button, and data preview](https://docs.mammoth.io/api/v1/images/20260615_101336_Screenshot2026-05-211559321.jpg)

See [Understanding data preview & query](https://docs.mammoth.io/learn/connectors/understanding-data-preview-query/) for a full guide.

## Step 4: Save the MySQL dataset

1. Enter a **dataset name** in the **Save table as** field
2. Check the **Update Method** (the default is **Replace all data**). To change it, click the edit icon, pick an option, and click **Save changes**:
   - **Replace all data**—Replaces all existing data
   - **Add new data**—Adds new data based on a unique sequential column
   - **Replace with new data**—Replaces existing data with new data based on a unique sequential column
   For **Add new data** and **Replace with new data**, also choose a **Key column**—a numeric or date column with incrementing values, such as an ID or a date.
3. Click **Save as dataset**. When the dataset is saved, click **Done**

## Keep MySQL data up to date

Set up a **Dataset Refresh** automation to refresh your MySQL dataset on a schedule.

## Troubleshoot MySQL connections

### Connection fails

- Confirm Mammoth's IPs are allowed in your MySQL grants and firewall

- Check that your MySQL user has an external host entry, not just `localhost`:

  ```sql
  CREATE USER 'mammoth_reader'@'%' IDENTIFIED BY 'password';
  GRANT SELECT ON your_database.* TO 'mammoth_reader'@'%';
  ```

---
Source: https://docs.mammoth.io/learn/connectors/mysql.md · Updated: 2026-10-13