Skip to content

Commit 47e0893

Browse files
dacharycajhuh-mdb
andauthored
(DOCSP-32029): Add procedure to connect to an Atlas deployment (#300)
* Add procedure to connect to an Atlas deployment * Editing pass to improve readability * Remove distracting bin link * Incorporate review feedback * What does it look like if I use monospace in the section header? * Remove Install info from Learn More * Apply suggestions from review Co-authored-by: Alison Huh <[email protected]> * Change the Learn More step to a note --------- Co-authored-by: Alison Huh <[email protected]>
1 parent edb8c5c commit 47e0893

File tree

1 file changed

+64
-2
lines changed

1 file changed

+64
-2
lines changed

source/connect.txt

Lines changed: 64 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,13 +13,75 @@ Connect to a Deployment
1313
:class: singlecol
1414

1515
This page shows how to use the |mdb-shell| to connect to a MongoDB
16-
deployment.
16+
deployment. You can connect to a
17+
`MongoDB Atlas cloud-hosted deployment <https://www.mongodb.com/docs/atlas>`__,
18+
connect to a local deployment, or connect to another remote host with
19+
|mdb-shell|.
1720

1821
Prerequisites
1922
-------------
2023

2124
.. include:: /includes/fact-connect-prereqs.rst
22-
25+
26+
Install ``mongosh``
27+
~~~~~~~~~~~~~~~~~~~
28+
29+
These procedures assume you have already installed ``mongosh``. For more
30+
information about installing ``mongosh``, refer to
31+
:ref:`mdb-shell-install`.
32+
33+
Connect to a MongoDB Atlas Deployment
34+
-------------------------------------
35+
36+
You can connect to your MongoDB Atlas deployment directly from your shell.
37+
38+
.. procedure::
39+
:style: normal
40+
41+
.. step:: Get your Atlas Connection String
42+
43+
You need an Atlas connection string to connect from |mdb-shell|.
44+
You can get the Atlas connection string in the Atlas UI.
45+
46+
Refer to the
47+
`Find Your MongoDB Atlas Connection String
48+
<https://www.mongodb.com/docs/manual/reference/connection-string/#find-your-mongodb-atlas-connection-string>`__
49+
guide for details.
50+
51+
.. step:: Set Your Database Credentials
52+
53+
If you haven't already
54+
`created a database user
55+
<https://www.mongodb.com/docs/atlas/tutorial/create-mongodb-user-for-cluster/>`__,
56+
you must set a username and password. To connect to Atlas, pass your username with the connection string.
57+
the connection string to connect to Atlas. After you issue the
58+
connect command, the shell prompts for your password.
59+
60+
.. step:: Connect to MongoDB Atlas with ``mongosh``
61+
62+
To establish your connection, run the ``mongosh`` command with your connection string and options
63+
to establish the connection.
64+
65+
The connection string includes the following elements:
66+
67+
- Your cluster name
68+
- A hash
69+
- A flag for the API version
70+
- A flag for the username you want to use to connect
71+
72+
It resembles the following string:
73+
74+
.. code-block:: sh
75+
76+
mongosh "mongodb+srv://YOUR_CLUSTER_NAME.YOUR_HASH.mongodb.net/" --apiVersion YOUR_API_VERSION --username YOUR_USERNAME
77+
78+
.. note:: Learn More
79+
80+
You can use other connection security options to connect to Atlas via
81+
``mongosh``. For information on connecting with a private
82+
IP for peering or a Private Endpoint connection, refer to the
83+
`Atlas Connect via mongosh <https://www.mongodb.com/docs/atlas/mongo-shell-connection/#choose-your-connection-security>`__
84+
documentation.
2385

2486
Connect to a Local Deployment on the Default Port
2587
-------------------------------------------------

0 commit comments

Comments
 (0)