Skip to content

Commit cd4e250

Browse files
author
Dave Cuthbert
authored
DOCSP-25800 command line connection support (#442)
* DOCSP-25900 comandline connection support * Staging fixes * Staging fixes * Staging fixes * Review feedback * Force build * Force build * Review feedback
1 parent b15d8d7 commit cd4e250

File tree

3 files changed

+160
-8
lines changed

3 files changed

+160
-8
lines changed

source/connect.txt

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -84,32 +84,44 @@ on GitHub.
8484

8585
.. include:: /includes/steps/starting-compass-paste-string.rst
8686

87+
Connecting with Compass from the Command Line
88+
----------------------------------------------
89+
90+
91+
.. include:: /includes/intro-command-line-connection.rst
92+
93+
For details, see :ref:`comp-command-line-connect`.
94+
8795
.. _advanced-connection-options:
8896

8997
Advanced Connection Options
9098
---------------------------
9199

92-
The Advanced Connection Options provide additonal forms of connecting
93-
|compass-short| deployments.
100+
The Advanced Connection Options provide additional forms of connecting
101+
|compass-short| to MongoDB.
94102

95-
:doc:`/connect/general-connection`
103+
:ref:`general-connection-tab`
96104
Learn how to select a Connection String Scheme for your deployment.
97105

98-
:doc:`/connect/authentication-connection`
106+
:ref:`authentication-connection-tab`
99107
Learn how to connect deployments that require authentication.
100108

101-
:doc:`/connect/tls-ssl-connection`
109+
:ref:`tls-ssl-tab`
102110
Learn how to connect deployments using TLS/SSL.
103111

104-
:doc:`/connect/ssh-connection`
112+
:ref:`ssh-connection`
105113
Learn how to connect deployments using an SSH tunnel.
106114

107-
:doc:`/connect/in-use-encryption`
115+
:ref:`in-use-encryption-tab`
108116
Learn how to connect deployments using In-Use Encryption.
109117

110-
:doc:`/connect/advanced-connection`
118+
:ref:`advanced-connection-tab`
111119
Learn about additional advanced connection options for your deployments.
112120

121+
:ref:`comp-command-line-connect`
122+
Learn how to open |compass-short| and connect to MongoDB from the
123+
command line.
124+
113125
.. seealso::
114126

115127
To learn how to disconnect your deployment, see :ref:`<disconnect-tab>`
@@ -125,4 +137,5 @@ The Advanced Connection Options provide additonal forms of connecting
125137
/connect/advanced-connection
126138
/connect/required-access
127139
/connect/favorite-connections
140+
/connect/connect-from-the-command-line
128141
/connect/disconnect
Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
.. _comp-command-line-connect:
2+
3+
===================================
4+
Start Compass from the Command Line
5+
===================================
6+
7+
.. default-domain:: mongodb
8+
9+
.. contents:: On this page
10+
:local:
11+
:backlinks: none
12+
:depth: 1
13+
:class: singlecol
14+
15+
.. include:: /includes/intro-command-line-connection.rst
16+
17+
There are two ways to start |compass-short| from the command line:
18+
19+
- :ref:`Specify a connection string on the command line
20+
<compass-connect-cmd-line>`
21+
- :ref:`Specify connection details in a file
22+
<compass-connect-file-based>`
23+
24+
If your connection string contains sensitive information, consider
25+
using a configuration file to avoid exposing that information on
26+
the command line.
27+
28+
.. _compass-executable-location:
29+
30+
Compass Executable Location
31+
---------------------------
32+
33+
The name and location of the |compass-short| executable varies by
34+
operating system.
35+
36+
Linux
37+
~~~~~
38+
The executable is called ``mongodb-compass``. The installer installs it
39+
in the ``/usr/bin`` directory.
40+
41+
Windows
42+
~~~~~~~
43+
44+
The executable is called ``MongoDBCompass.exe``. The installer installs
45+
it in a folder you pick during the installation process.
46+
47+
MacOS
48+
~~~~~
49+
The executable is called ``Compass``. The installer installs
50+
it under the Applications folder:
51+
52+
.. code-block:: shell
53+
54+
/Applications/MongoDB\ Compass.app/Contents/MacOS/MongoDB\ Compass
55+
56+
.. _compass-connect-cmd-line:
57+
58+
Command Line Connection Specification
59+
-------------------------------------
60+
61+
The command line invocation for |compass-short| has two components, the
62+
path to the |compass-short| executable and a connection string. The
63+
format is:
64+
65+
.. code-block:: shell
66+
:copyable: false
67+
68+
<path/to/compass/executable> <connection string>
69+
70+
This example is like the basic connection string for a `MongoDB
71+
University <https://learn.mongodb.com/>`__ training cluster. Modify the
72+
connection details to connect to your MongoDB installation:
73+
74+
.. code-block:: shell
75+
:copyable: false
76+
77+
mongodb-compass mongodb+srv://cluster0.cpxklfq.mongodb.net/library
78+
79+
80+
.. _compass-connect-file-based:
81+
82+
Configuration File Connection Specification
83+
-------------------------------------------
84+
85+
The command line invocation for |compass-short| can specify a
86+
configuration file.
87+
88+
The format is:
89+
90+
.. code-block:: shell
91+
92+
<path/to/compass/executable> \
93+
--file=<filename> \
94+
[--passphrase=<passphrase>] \
95+
[<connection id>]
96+
97+
The components of the command invocation are:
98+
99+
- The path to the |compass-short| executable
100+
- A connection configuration file
101+
- An optional passphrase for the connection configuration file
102+
- An optional connection id
103+
104+
To create the connection configuration file, follow the steps to
105+
:ref:`export the connection details <compass-export-connections-cli>`
106+
from your Compass instance. The export process creates a file that
107+
includes all of your favorite connections.
108+
109+
.. important::
110+
111+
If you export your saved connections without using a passphrase, the
112+
configuration file contains the plaintext version of your username
113+
and password. Use a passphrase to encrypt the password.
114+
115+
To open |compass-short| and connect to your MongoDB instance, use a
116+
command line like:
117+
118+
.. code-block::
119+
:copyable: false
120+
121+
mongodb-compass --file=learningConnectionFile \
122+
--passphrase=superSecret
123+
124+
If you have multiple favorites, include the connection id from the
125+
configuration file to specify which connection to use:
126+
127+
.. code-block::
128+
:copyable: false
129+
130+
mongodb-compass --file=multipleConnectionFile \
131+
--passphrase=superSecret \
132+
27ba0eda-c27e-46f5-a74a-2c041b1b58c4
133+
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
You can start a |compass-short| session from the command line.
2+
3+
In enterprise environments, a scripted start can make it easier to
4+
deploy |compass-short|. For example, to limit access to sensitive
5+
systems, you can configure a command line start so that |compass-short|
6+
can run on a jump host.

0 commit comments

Comments
 (0)