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

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 read role 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

  1. Go to the Data Library, click New dataset, and choose Connectors.
  2. Search for MongoDB and click its tile. The connection form opens.
  3. Fill in the fields below and click Connect. If the check fails, the error appears at the bottom of the form.
  4. Once Mammoth has connected, the connector workspace opens on your collections. See Connect a database or app for the shared steps.
MongoDB New Connection form with Host URL, Port 27017, Username, Password, Database, and Display Name fields
FieldWhat to enterExample
Host URLHostname or IP address of your MongoDB servermongo.example.com
PortTCP port MongoDB listens on27017 (default)
UsernameMongoDB user with read accessmammoth_reader
PasswordPassword for the user
DatabaseName of the MongoDB database. Mammoth also signs the user in against this databaseanalytics
Display NameOptional label for this connectionMongoDB Atlas

Pick MongoDB collections and fields

  1. In Tables, click a collection to see its fields and sample rows.
  2. Tick the fields you want. They gather in Your table.
  3. Click Preview 100 rows to check the result.
MongoDB New Dataset dialog with collection list, SELECT query, preview of three rows, and Dataset saved message

Save MongoDB data as a dataset

  1. Click Save as dataset.
  2. Enter a Dataset name and pick the folder under Save in.
  3. Under Keep it up to date, choose Daily or Manual.
  4. Click Save.
MongoDB New Dataset dialog with Save table as, Update Method, and Save as dataset button below the preview

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 methodWhat it does
Replace all dataRebuilds the dataset from the source on every refresh
Add new rows onlyKeeps your rows 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)

A key column is a numeric or date column whose values only go up, such as an ID or a date.

Troubleshoot MongoDB connections

SymptomLikely causeFix
Connection failsPort 27017 is closed to MammothOpen port 27017 inbound from Mammoth's IP address
Connection fails on AtlasMammoth isn't on the Atlas allowlistCheck your Network Access list in the Atlas console
Connection fails on AtlasHost URL has no mongodb+srv:// prefix, so TLS is offEnter the host as mongodb+srv://cluster0.abc123.mongodb.net
Connection fails or no collectionsThe user lacks the read roleRun db.grantRolesToUser("mammoth_reader", [{ role: "read", db: "analytics" }])
Was this page helpful?

Something wrong? support@mammoth.io