Skip to content

Commit 35eca8a

Browse files
zach-carrjwilliams-mongommarcon
authored
(DOCSP-10666) Update mongosh connection page with --port and --host (#16)
* (DOCSP-10666) Add --host --port connection options Co-authored-by: jwilliams-mongo <55147273+jwilliams-mongo@users.noreply.github.com> Co-authored-by: Massimiliano Marcon <emaildelmax@gmail.com>
1 parent 9dc7040 commit 35eca8a

File tree

1 file changed

+45
-19
lines changed

1 file changed

+45
-19
lines changed

source/connect.txt

Lines changed: 45 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -34,43 +34,69 @@ This is equivalent to the following command:
3434

3535
.. code-block:: sh
3636

37-
mongosh "localhost:27017"
37+
mongosh "mongodb://localhost:27017"
3838

3939
Local MongoDB Instance on a Non-Default Port
4040
--------------------------------------------
4141

42-
To specify a port to connect to on localhost, use the
43-
:manual:`connection string </reference/connection-string>` format.
42+
To specify a port to connect to on localhost, you can use:
4443

45-
.. example::
44+
- A :manual:`connection string </reference/connection-string>`.
4645

47-
To connect to a MongoDB instance running on localhost with a
48-
non-default port 28015:
46+
.. example::
47+
48+
To connect to a MongoDB instance running on localhost with a
49+
non-default port 28015:
50+
51+
.. code-block:: sh
52+
53+
mongosh "mongodb://localhost:28015"
4954

50-
.. code-block:: sh
55+
- The command-line option ``--port``.
5156

52-
mongosh "localhost:28015"
57+
.. example::
58+
59+
To connect to a MongoDB instance running on localhost with a
60+
non-default port 28015:
61+
62+
.. code-block:: sh
63+
64+
mongosh --port 28015
5365

5466
MongoDB Instance on a Remote Host
5567
---------------------------------
5668

57-
To specify a remote host and port, use a
58-
:manual:`connection string </reference/connection-string>`.
69+
To specify a remote host and port, you can use:
5970

60-
.. example::
71+
- A :manual:`connection string </reference/connection-string>`.
6172

62-
To connect to a MongoDB
63-
instance running on a remote host machine on port 28015:
73+
.. example::
6474

65-
.. code-block:: sh
75+
To connect to a MongoDB
76+
instance running on a remote host on port 28015:
77+
78+
.. code-block:: sh
79+
80+
mongosh "mongodb://mongodb0.example.com:28015"
6681

67-
mongosh "mongodb://mongodb0.example.com:28015"
82+
.. note:: Connecting to |service|
83+
84+
If your remote host is a |service-fullname| cluster, you can copy
85+
your connection string from the |service| UI. To learn more, see
86+
:atlas:`Connect to a Cluster <connect-to-cluster/#use-the-connect-dialog-to-connect-to-your-cluster>`.
6887

69-
.. note:: Connecting to |service|
88+
- The command-line options ``--host`` and ``--port``. If you do not
89+
include the ``--port`` option, ``mongosh`` uses the **default port**
90+
27017.
91+
92+
.. example::
93+
94+
To connect to a MongoDB
95+
instance running on a remote host on port 28015:
96+
97+
.. code-block:: sh
7098

71-
If your remote host is a |service-fullname| cluster, you can copy
72-
your connection string from the |service| UI. To learn more, see
73-
:atlas:`Connect to a Cluster <connect-to-cluster/#use-the-connect-dialog-to-connect-to-your-cluster>`.
99+
mongosh --host mongodb0.example.com --port 28015
74100

75101
Connection Options
76102
------------------

0 commit comments

Comments
 (0)