Stay organized with collections
Save and categorize content based on your preferences.
Relevant to Cloud Firestore Enterprise edition only.
Learn how to create a Cloud Firestore with MongoDB compatibility database and connect to it with the
mongosh tool.
Before you begin
If you haven't already, create a Firebase project: In the
Firebase console, click Add project,
then follow the on-screen instructions to create a Firebase project or to
add Firebase services to an existing Google Cloud project.
Create a Cloud Firestore with MongoDB compatibility database and retrieve the connection string
In the Firebase console, create a new Firestore Enterprise edition database.
Cloud Firestore with MongoDB compatibility requires Firestore Enterprise edition:
In the Firebase console, go to the Firestore Database page.
Select an Identity and Access Management role for the user.
Click create. The database creates a user and shows you the user's
generated password. Copy and save this password. You will not be able to retrieve
this password later..
Connect using mongosh
Use the connection string, username, and password to connect to your
database, run mongosh locally with the following configuration options.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-08-25 UTC."],[],[],null,["\u003cbr /\u003e\n\n\n|--------------------------------------------------------|\n| *Relevant to Cloud Firestore Enterprise edition only.* |\n\n\u003cbr /\u003e\n\nLearn how to create a Cloud Firestore with MongoDB compatibility database and connect to it with the\n`mongosh` tool.\n\nBefore you begin\n\n1. If you haven't already, create a Firebase project: In the [Firebase console](//console.firebase.google.com/), click **Add project** , then follow the on-screen instructions to create a Firebase project or to add Firebase services to an existing Google Cloud project.\n2. [Install the `mongosh` tool](https://www.mongodb.com/docs/mongodb-shell/install/)\n\n\u003cbr /\u003e\n\nCreate a Cloud Firestore with MongoDB compatibility database and retrieve the connection string In the Firebase console, create a new Firestore Enterprise edition database. Cloud Firestore with MongoDB compatibility requires Firestore Enterprise edition:\n1. In the Firebase console, go to the **Firestore Database** page.\n\n [Go to Firestore Database](//console.firebase.google.com/project/_/firestore/databases/-default-/data/)\n2. Click the database that you want to authenticate.\n3. In the **Explorer** panel, click more_vert **View more**.\n4. Select **Connect using MongoDB tools**.\n5. Copy the connection string.\n\n\u003cbr /\u003e\n\nThe connection string depends on the UID of the database (system-generated)\nand the location of database: \n\n```text\nUID.LOCATION.firestore.goog\n```\n\nCreate a user for SCRAM authentication\n\nIn the Google Cloud console, create a new database user and assign\nthe user Identity and Access Management permissions.\n\n1. In the Google Cloud console, go to the **Databases** page.\n\n [Go to Databases](https://console.cloud.google.com/firestore/databases)\n2. Select the database from the list of databases.\n3. In the navigation menu, click **Auth**.\n4. Click **Add User**.\n5. Enter a username.\n6. Select an Identity and Access Management role for the user.\n7. Click create. The database creates a user and shows you the user's generated password. **Copy and save this password. You will not be able to retrieve\n this password later.**.\n\nConnect using `mongosh`\n\nUse the connection string, username, and password to connect to your\ndatabase, run `mongosh` locally with the following configuration options. \n\n```gdscript\nmongosh 'mongodb://\u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e:\u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e@\u003cvar translate=\"no\"\u003eCONNECTION_STRING\u003c/var\u003e:443/\u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e?loadBalanced=true&authMechanism=SCRAM-SHA-256&tls=true&retryWrites=false'\n```\n\nReplace the following:\n\n- \u003cvar translate=\"no\"\u003eUSERNAME\u003c/var\u003e: the name of the database user you created.\n- \u003cvar translate=\"no\"\u003ePASSWORD\u003c/var\u003e: the generated password for the database user you created.\n- \u003cvar translate=\"no\"\u003eCONNECTION_STRING\u003c/var\u003e: the database connection string.\n- \u003cvar translate=\"no\"\u003eDATABASE_ID\u003c/var\u003e: a database ID\n\nOnce connected, you can create and read data, for example: \n\n```text\ndb.pages.insertOne({ message: \"Hello World!\"})\ndb.pages.find({})\nexit\n```\n\nWhat's next\n\n- [See a list of supported features](/docs/firestore/enterprise/supported-data-types-drivers)\n- [Learn about behavior differences in Cloud Firestore with MongoDB compatibility](/docs/firestore/enterprise/behavior-differences)\n- [Learn about additional authentication methods](/docs/firestore/enterprise/connect)"]]