Connect MongoDB or MongoDB Atlas to Mammoth
The MongoDB connector imports documents from a MongoDB collection into Mammoth as rows in a dataset. Open it from Data Library > New dataset > Connectors and search for MongoDB. 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 MongoDB
- The documents in any collection the user can read, one row per document.
- Only the fields you tick.
MongoDB has collections only, so the workspace has no SQL query view for it. AI query writing isn't available for MongoDB.
Before you connect MongoDB
You need:
- A MongoDB instance reachable from the internet, such as a MongoDB Atlas cluster.
- A MongoDB user with the
readrole on the database you want to import from. - The server's hostname, port (default
27017), database name, username and password. - Mammoth's IP address added to your MongoDB network allowlist. See Allow Mammoth through your firewall.
Find your MongoDB Atlas hostname
In Atlas, go to Atlas → Database → Connect → Connect your application. The hostname looks like cluster0.abc123.mongodb.net. Enter it in Host URL with the mongodb+srv:// prefix, for example mongodb+srv://cluster0.abc123.mongodb.net. Mammoth turns on TLS only when Host URL starts with mongodb+srv://, and Atlas requires TLS. Add Mammoth's IP address to your Atlas Network Access allowlist.
Connect MongoDB to Mammoth
- Go to the Data Library, click New dataset, and choose Connectors.
- Search for MongoDB and click its tile. The connection form opens.
- Fill in the fields below and click Connect. If the check fails, the error appears at the bottom of the form.
- Once Mammoth has connected, the connector workspace opens on your collections. See Connect a database or app for the shared steps.
| Field | What to enter | Example |
|---|---|---|
| Host URL | Hostname or IP address of your MongoDB server | mongo.example.com |
| Port | TCP port MongoDB listens on | 27017 (default) |
| Username | MongoDB user with read access | mammoth_reader |
| Password | Password for the user | |
| Database | Name of the MongoDB database. Mammoth also signs the user in against this database | analytics |
| Display Name | Optional label for this connection | MongoDB Atlas |
Pick MongoDB collections and fields
- In Tables, click a collection to see its fields and sample rows.
- Tick the fields you want. They gather in Your table.
- Click Preview 100 rows to check the result.
Save MongoDB data as a dataset
- Click Save as dataset.
- Enter a Dataset name and pick the folder under Save in.
- Under Keep it up to date, choose Daily or Manual.
- Click Save.
Refresh MongoDB data and choose an update method
Choosing Daily creates a Dataset Refresh automation that you can reschedule later.
After the dataset is saved, its Update method offers these options:
| Update method | What it does |
|---|---|
| Replace all data | Rebuilds the dataset from the source on every refresh |
| Add new rows only | Keeps your rows and adds rows above the last value of a Key column |
| Keep only the newest rows | Empties the dataset, then brings in rows since the last refresh (needs a Key column) |
A key column is a numeric or date column whose values only go up, such as an ID or a date.
Troubleshoot MongoDB connections
| Symptom | Likely cause | Fix |
|---|---|---|
| Connection fails | Port 27017 is closed to Mammoth | Open port 27017 inbound from Mammoth's IP address |
| Connection fails on Atlas | Mammoth isn't on the Atlas allowlist | Check your Network Access list in the Atlas console |
| Connection fails on Atlas | Host URL has no mongodb+srv:// prefix, so TLS is off | Enter the host as mongodb+srv://cluster0.abc123.mongodb.net |
| Connection fails or no collections | The user lacks the read role | Run db.grantRolesToUser("mammoth_reader", [{ role: "read", db: "analytics" }]) |
Related
- Connect a database or app: the shared connector workspace steps.
- Allow Mammoth through your firewall: the IP address to allow.
- Manage saved connections: edit, reuse or delete this connection.
- Refresh a dataset: change when the dataset refreshes.
- Connector reference: every source Mammoth connects to.
Something wrong? support@mammoth.io