Skip to content
Learn › Get data in › Connectors: open the docs menu

Connect MySQL to Mammoth and import tables or SQL

The MySQL connector imports a whole table, or the rows, columns or joined data from your own SQL query, into Mammoth as a dataset. Open it from Data Library > New dataset > Connectors and search for MySQL. Project Admins create the connection; Project Editors can start datasets from a connection the project already has. Which connectors you can add depends on your plan.

What you can bring in from MySQL

  • Any table the database user can read.
  • The result of your own SELECT query.
  • A query Mammoth writes from a plain-language description, when AI query is on for your workspace.

The dataset can refresh daily or only when you ask.

Before you connect MySQL

You need:

  • A MySQL server reachable from the internet.
  • A database user with SELECT permission on the tables you want to import.
  • The server's hostname or IP address, port (default 3306), database name, username and password.
  • Mammoth's IP address added to your MySQL firewall allowlist. The connection form shows the address. See Allow Mammoth through your firewall, which includes the user setup needed for external access.

Connect MySQL to Mammoth

These steps follow the shared flow in Connect a database or app.

  1. Go to the Data Library and click New dataset.
  2. Choose Connectors.
  3. Search for MySQL and click its tile. The connection form opens.
  4. Fill in the fields below.
  5. Click Connect. Mammoth checks the details and saves the connection. If the check fails, the error appears at the bottom of the form.

MySQL - New Connection form with Host URL, Port 3306, Username, Password, Database and Display Name

FieldWhat to enterExample
Host URLHostname or IP address of your MySQL servermysql.example.com
PortTCP port MySQL listens on3306 (default)
UsernameDatabase user with SELECT accessmammoth_reader
PasswordPassword for the database user
DatabaseName of the database to connect toecommerce_db
Display NameOptional label for this connection in MammothMySQL Production

Once connected, the connector workspace opens on your tables.

Query a MySQL table in the SQL view

  1. In Tables, click a table. Mammoth opens its rows with the SELECT * query that read them, shown above the rows.
  2. To change the query, click Edit SQL, edit it, and click Run (or press Ctrl+Enter).
  3. To keep only some columns, tick them in the table header.

MySQL uses backticks around identifiers:

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

Write a MySQL query from a description

When AI query is on for your workspace, click Edit SQL to see the Describe the data you need... box above the editor.

  1. Describe what you want, for example "all shipped orders in the last 90 days with customer IDs".
  2. Click Write SQL. Mammoth writes the query from your table structure.
  3. Check the query, then click Run.

If a query fails, click Fix with AI to ask the chat to correct it.

Edit query dialog with table list, AI description box, SQL editor, Run button, and data preview

Connect a database or app covers the full SQL view.

Save MySQL data as a dataset

  1. Click Save as dataset.
  2. Enter a Name and choose a folder under Save in.
  3. Under Keep it up to date, choose Daily at 06:00 or Only when I ask.
  4. Under On each refresh, click Change and pick what a refresh does (see the table below).
  5. Click Save as dataset. When the dataset is ready, click Open dataset.
On each refreshWhat it does
Replace all rowsMatches the source after every refresh. This is the default.
Add only new rowsKeeps what you have and adds rows above the last value of a Key column
Keep only the newest rowsEmpties the dataset, then brings in rows since the last refresh (needs a Key column)
Add every row againShown when the query has no column that can serve as a key column, so each refresh adds a full copy

Refresh MySQL data on a schedule

Choosing Daily at 06:00 creates a Dataset Refresh automation for the dataset. To run it on another schedule, edit that automation. For a dataset saved with Only when I ask, create a Dataset Refresh automation yourself.

After you save, you can change what a refresh does in the dataset's Update method setting. It offers Replace all data, Add new rows only and Keep only the newest rows.

Troubleshoot MySQL connections

SymptomLikely causeFix
Connection failsMammoth's IP address isn't allowedAllow Mammoth's IP address in your MySQL grants and firewall
Connection failsThe MySQL user has only a localhost host entryCreate the user with an external host entry (see below)

Create a user that can connect from outside localhost:

CREATE USER 'mammoth_reader'@'%' IDENTIFIED BY 'password';
GRANT SELECT ON your_database.* TO 'mammoth_reader'@'%';
Was this page helpful?

Something wrong? support@mammoth.io