Skip to content

Commit 88f782a

Browse files
authored
MongoDB connectors: connection string example, how-to, and terminology (#321)
1 parent 86bb7c7 commit 88f782a

File tree

3 files changed

+22
-4
lines changed

3 files changed

+22
-4
lines changed

snippets/general-shared-text/mongodb-cli-api.mdx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ For a MongoDB Atlas deployment, the following environment variables:
1414

1515
- `MONGODB_COLLECTION` - The name of the collection in the database, represented by `--collection` (CLI) or `collection` (Python).
1616

17-
- `MONGODB_URI` - The URI for the cluster, represented by `--uri` (CLI) or `uri` (Python).
17+
- `MONGODB_URI` - The connection string for the cluster, represented by `--uri` (CLI) or `uri` (Python).
1818

1919
For a local MongoDB server, the following environment variables:
2020

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Fill in the following fields:
22

33
- **Name** (_required_): A unique name for this connector.
4-
- **URI** (_required_): The MongoDB instance connection URI.
54
- **Database** (_required_): The name of the database on the instance.
6-
- **Collection** (_required_): The name of the collection within the database.
5+
- **Collection** (_required_): The name of the collection within the database.
6+
- **Connection String** (_required_): The MongoDB instance connection string.

snippets/general-shared-text/mongodb.mdx

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,4 +17,22 @@ allowfullscreen
1717
- The cluster must have at least one database. [Create a database](https://www.mongodb.com/docs/compass/current/databases/#create-a-database).
1818
- The database must have at least one user, and that user must have sufficient access to the database. [Create a database user](https://www.mongodb.com/docs/atlas/security-add-mongodb-users/#add-database-users). [Give the user database access](https://www.mongodb.com/docs/manual/core/authorization/).
1919
- The database must have at least one collection. [Create a collection](https://www.mongodb.com/docs/compass/current/collections/#create-a-collection).
20-
- The URI for the cluster. This URI must include the protocol, username, password, and host. [Learn how to get this value](https://www.mongodb.com/resources/products/fundamentals/mongodb-connection-string).
20+
- The connection string for the cluster. For MongoDB Atlas, this connection string must include the protocol, username, password, host, and cluster name. For example:
21+
22+
```text
23+
mongodb+srv://<db_user>:<db_password>@<host>/?retryWrites=true&w=majority&appName=<cluster>
24+
```
25+
26+
To get the connection string in MongoDB Atlas, do the following:
27+
28+
1. Log in to your MongoDB Atlas console.
29+
2. In the sidebar, under **Databases**, click **Clusters**.
30+
3. Click on the cluster you want to connect to.
31+
4. Click **Connect**, or click the **Cmd Line Tools** tab and then click **Connect Instructions**.
32+
5. Click **Drivers**.
33+
6. Under **Add your connection string into your application code**, copy the connection string.
34+
You can then close the **Connect** dialog in MongoDB Atlas.
35+
36+
Before you use this connection string, be sure to fill in any placeholders in the string, such as your MongoDB Atlas database user's password value.
37+
38+
[Learn more](https://www.mongodb.com/resources/products/fundamentals/mongodb-connection-string).

0 commit comments

Comments
 (0)