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
-
In the Google Cloud console, go to the project selector page.
-
Select or create a Google Cloud project.
Roles required to select or create a project
- Select a project: Selecting a project doesn't require a specific IAM role—you can select any project that you've been granted a role on.
-
Create a project: To create a project, you need the Project Creator
(
roles/resourcemanager.projectCreator
), which contains theresourcemanager.projects.create
permission. Learn how to grant roles.
-
Verify that billing is enabled for your Google Cloud project.
-
Make sure that you have the following role or roles on the project: Cloud Datastore Owner
Check for the roles
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
-
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.
- 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
-
In the Google Cloud console, go to the IAM page.
Go to IAM - Select the project.
- Click Grant access.
-
In the New principals field, enter your user identifier. This is typically the email address for a Google Account.
- In the Select a role list, select a role.
- To grant additional roles, click Add another role and add each additional role.
- Click Save.
-
- 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:-
In the Google Cloud console, go to the Databases page.
- Click Create a Firestore Database.
- Enter a database ID.
- Select Enterprise Edition.
- Select a location for your database.
Click Create Database.
When the database completes initialization, the console opens the Firestore Studio for your database.
-
In the Connect to Firestore using an external MongoDB tool section, copy the connection string.