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.
Crea una base de datos de Firestore con compatibilidad con MongoDB y recupera la cadena de conexión
En la consola de Google Cloud , crea una nueva base de datos de la edición de Firestore Enterprise.
Firestore con compatibilidad con MongoDB requiere la edición Enterprise de Firestore:
En la consola de Google Cloud , ve a la página Bases de datos.
Selecciona un rol de Identity and Access Management para el usuario.
Haz clic en Crear. La base de datos crea un usuario y te muestra la contraseña generada. Copia y guarda esta contraseña. No podrás recuperar esta contraseña más adelante.
Conéctate con mongosh
Usa la cadena de conexión, el nombre de usuario y la contraseña para conectarte a tu base de datos y ejecutar mongosh de forma local con las siguientes opciones de configuración.
Haz clic en more_vertVer más en la columna Acciones de la base de datos que quieras borrar. Haga clic en Borrar. Aparecerá un cuadro de diálogo.
En el cuadro de diálogo ¿Quieres borrar la base de datos?, escribe el ID de la base de datos en el campo de texto para confirmar la eliminación. Haz clic en Borrar. La consola te informa sobre el éxito o el fracaso de la operación.
[[["Fácil de comprender","easyToUnderstand","thumb-up"],["Resolvió mi problema","solvedMyProblem","thumb-up"],["Otro","otherUp","thumb-up"]],[["Difícil de entender","hardToUnderstand","thumb-down"],["Información o código de muestra incorrectos","incorrectInformationOrSampleCode","thumb-down"],["Faltan la información o los ejemplos que necesito","missingTheInformationSamplesINeed","thumb-down"],["Problema de traducción","translationIssue","thumb-down"],["Otro","otherDown","thumb-down"]],["Última actualización: 2025-08-18 (UTC)"],[],[],null,["Quickstart: Create a database and connect to it\n\nLearn how to create a Firestore with MongoDB compatibility database and connect to it with the\n`mongosh` tool.\n\nBefore you begin\n\n1. In the Google Cloud console, go to the project selector page.\n\n [Go to project selector](https://console.cloud.google.com/projectselector2/home/dashboard)\n2. Select or create a Google Cloud project.\n\n | **Note**: If you don't plan to keep the resources that you create in this procedure, create a project instead of selecting an existing project. After you finish these steps, you can delete the project, removing all resources associated with the project.\n3.\n [Verify that billing is enabled for your Google Cloud project](/billing/docs/how-to/verify-billing-enabled#confirm_billing_is_enabled_on_a_project).\n\n4.\n\n Make sure that you have the following role or roles on the project:\n\n Cloud Datastore Owner\n\n Check for the roles\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3.\n In the **Principal** column, find all rows that identify you or a group that\n you're included in. To learn which groups you're included in, contact your\n administrator.\n\n 4. For all rows that specify or include you, check the **Role** column to see whether the list of roles includes the required roles.\n\n Grant the roles\n 1.\n In the Google Cloud console, go to the **IAM** page.\n\n [Go to IAM](https://console.cloud.google.com/projectselector/iam-admin/iam?supportedpurview=project)\n 2. Select the project.\n 3. Click person_add **Grant access**.\n 4.\n In the **New principals** field, enter your user identifier.\n\n This is typically the email address for a Google Account.\n\n 5. In the **Select a role** list, select a role.\n 6. To grant additional roles, click add **Add\n another role** and add each additional role.\n 7. Click **Save**.\n5. [Install the `mongosh` tool](https://www.mongodb.com/docs/mongodb-shell/install/)\n\n\u003cbr /\u003e\n\nCreate 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:\n\n\u003cbr /\u003e\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. Click **Create a Firestore Database**.\n3. Enter a database ID.\n4. Select Enterprise Edition.\n5. Select a location for your database.\n6. Click **Create Database**.\n\n When the database completes initialization,\n the console opens the **Firestore Studio** for your database.\n7. In the **Connect to Firestore using an external MongoDB tool**\n section, 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](/firestore/mongodb-compatibility/docs/supported-data-types-drivers)\n- [Learn about behavior differences in Firestore with MongoDB compatibility](/firestore/mongodb-compatibility/docs/behavior-differences)\n- [Learn about additional authentication methods](/firestore/mongodb-compatibility/docs/connect)"]]