Quickstart: Create a database and connect to it

Learn how to create a Firestore with MongoDB compatibility database and connect to it with the mongosh tool.

Before you begin

  1. In the Google Cloud console, go to the project selector page.

    Go to project selector

  2. Select or create a Google Cloud project.

  3. Verify that billing is enabled for your Google Cloud project.

  4. Make sure that you have the following role or roles on the project: Cloud Datastore Owner

    Check for the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. In the Principal column, find all rows that identify you or a group that you're included in. To learn which groups you're included in, contact your administrator.

    4. For all rows that specify or include you, check the Role column to see whether the list of roles includes the required roles.

    Grant the roles

    1. In the Google Cloud console, go to the IAM page.

      Go to IAM
    2. Select the project.
    3. Click Grant access.
    4. In the New principals field, enter your user identifier. This is typically the email address for a Google Account.

    5. In the Select a role list, select a role.
    6. To grant additional roles, click Add another role and add each additional role.
    7. Click Save.
  5. Install the mongosh tool

Create a Firestore with MongoDB compatibility database and retrieve the connection string

In the Google Cloud console, create a new Firestore Enterprise edition database. Firestore with MongoDB compatibility requires Firestore Enterprise edition:

  1. In the Google Cloud console, go to the Databases page.

    Go to Databases

  2. Click Create a Firestore Database.
  3. Enter a database ID.
  4. Select Enterprise Edition.
  5. Select a location for your database.
  6. Click Create Database.

    When the database completes initialization, the console opens the Firestore Studio for your database.

  7. In the Connect to Firestore using an external MongoDB tool section, copy the connection string.