Skip to content
Learn › Connectors: open the docs menu

MongoDB connector

The MongoDB connector imports data from your MongoDB database into Mammoth as a dataset. Select a collection from the browser or write a query to import documents as rows.

Before you start

You need:

  • A MongoDB instance accessible from the internet
  • A MongoDB user with read access on the database you want to import from
  • Your server's hostname, port (default: 27017), database name, username, and password
  • Mammoth's IP address added to your MongoDB network allowlist—see Network requirements

Step 1: Select the MongoDB connector

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

Step 2: Create a connection

Click New Connection to open the credential form.

MongoDB New Connection form with Host URL, Port 27017, Username, Password, Database, and Display Name fields
FieldDescriptionExample
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 databaseanalytics
Display NameOptional label for this connectionMongoDB Atlas

Tip: MongoDB Atlas. If you're using MongoDB Atlas, find your connection hostname in Atlas → Database → Connect → Connect your application. It looks like cluster0.abc123.mongodb.net. Use port 27017 and add Mammoth's IP address to your Atlas Network Access allowlist.

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.

Step 3: Select a MongoDB collection and query your data

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

Write a custom MongoDB query

Use the Enter SQL query editor to filter documents or select specific fields. You query your MongoDB collections with SQL:

SELECT _id, name, email, createdAt
FROM customers
WHERE status = 'active'
MongoDB New Dataset dialog with collection list, SELECT query, preview of three rows, and Dataset saved message

See Understanding data preview & query for a full guide.

Step 4: Save the MongoDB 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
MongoDB New Dataset dialog with Save table as, Update Method, and Save as dataset button below the preview

Troubleshoot MongoDB connections

Connection fails

  • Confirm port 27017 is open inbound from Mammoth's IP address
  • For MongoDB Atlas, check your Network Access list in the Atlas console
  • Verify the user has read role on the database: db.grantRolesToUser("mammoth_reader", [{ role: "read", db: "analytics" }])

Report an issue · support@mammoth.io