@@ -34,43 +34,69 @@ This is equivalent to the following command:
34
34
35
35
.. code-block:: sh
36
36
37
- mongosh "localhost:27017"
37
+ mongosh "mongodb:// localhost:27017"
38
38
39
39
Local MongoDB Instance on a Non-Default Port
40
40
--------------------------------------------
41
41
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:
44
43
45
- .. example::
44
+ - A :manual:`connection string </reference/connection-string>`.
46
45
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"
49
54
50
- .. code-block:: sh
55
+ - The command-line option ``--port``.
51
56
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
53
65
54
66
MongoDB Instance on a Remote Host
55
67
---------------------------------
56
68
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:
59
70
60
- .. example::
71
+ - A :manual:`connection string </reference/connection-string>`.
61
72
62
- To connect to a MongoDB
63
- instance running on a remote host machine on port 28015:
73
+ .. example::
64
74
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"
66
81
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>`.
68
87
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
70
98
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
74
100
75
101
Connection Options
76
102
------------------
0 commit comments