@@ -12,4 +12,154 @@ Import Favorite Connections with the CLI
12
12
:depth: 2
13
13
:class: singlecol
14
14
15
- TODO: Write
15
+ You can use the |compass-short| :abbr:`CLI (Command-Line Interface)` to
16
+ import favorite connections. This lets you use saved connections from
17
+ other workspaces or connections used by other team members.
18
+
19
+ Prerequisite
20
+ ------------
21
+
22
+ To import favorite connections, you must first :ref:`export the
23
+ connections <compass-export-connections-cli>`.
24
+
25
+ Import Encrypted Favorite Connections
26
+ -------------------------------------
27
+
28
+ Use this procedure to import a list of favorite connections that is
29
+ :ref:`encrypted with a passphrase
30
+ <compass-export-connections-cli-encrypted>`.
31
+
32
+ Procedure
33
+ ~~~~~~~~~
34
+
35
+ To import unencrypted favorite connections with the |compass-short|
36
+ :abbr:`CLI (Command-Line Interface)`, specify:
37
+
38
+ - The path to the |compass| executable. The name and filepath of the
39
+ executable depend on your operating system.
40
+
41
+ - The ``--import-connections`` option set to the destination of the file
42
+ containing favorite connections.
43
+
44
+ - The ``--passphrase`` option set to the passphrase used to encrypt the
45
+ exported file.
46
+
47
+ Your operation should resemble the following prototype:
48
+
49
+ .. code-block:: sh
50
+
51
+ <path-to-Compass-executable> \
52
+ --import-connections=<filename> \
53
+ --passphrase=<passphrase>
54
+
55
+ Example
56
+ ~~~~~~~
57
+
58
+ The following example imports favorite |compass-short| connections from
59
+ a file with the path
60
+ ``/tmp/compass-connections/favorites-encrypted.json`` that is encrypted
61
+ with the passphrase ``abc123``.
62
+
63
+ Run the following command in the folder containing your MongoDB Compass
64
+ executable:
65
+
66
+ .. code-block:: sh
67
+
68
+ ./MongoDB\ Compass \
69
+ --import-connections=/tmp/compass-connections/favorites-encrypted.json \
70
+ --passphrase=abc123
71
+
72
+ .. note::
73
+
74
+ The name and file path of the executable depend on your operating
75
+ system. The preceding command is for macOS.
76
+
77
+ Results
78
+ ```````
79
+
80
+ After you run the import command, you will see this output:
81
+
82
+ .. code-block:: sh
83
+ :copyable: false
84
+
85
+ Importing connections from "/tmp/compass-connections/favorites-encrypted.json" (with passphrase)
86
+
87
+ MongoDB Compass starts and you will see the imported connections under
88
+ :guilabel:`Saved Connections` on the Connect screen.
89
+
90
+ Errors
91
+ ~~~~~~
92
+
93
+ When you try to import encrypted favorite connections, you may
94
+ see these errors:
95
+
96
+ - If do not specify a passphrase, you will see this error:
97
+
98
+ .. code-block:: sh
99
+ :copyable: false
100
+
101
+ Failed to perform operation Be [Error]: Input file contains encrypted
102
+ secrets but no passphrase was provided
103
+
104
+ - If you specify an incorrect passphrase, you will see this error:
105
+
106
+ .. code-block:: sh
107
+ :copyable: false
108
+
109
+ Failed to perform operation Be [Error]: Cannot decrypt due to corrupt
110
+ data or wrong passphrase
111
+
112
+ Import Unencrypted Favorite Connections
113
+ ---------------------------------------
114
+
115
+ Use this procedure to import a list of favorite connections that is not
116
+ encrypted with a passphrase.
117
+
118
+ Procedure
119
+ ~~~~~~~~~
120
+
121
+ To import unencrypted favorite connections with the |compass-short|
122
+ :abbr:`CLI (Command-Line Interface)`, specify:
123
+
124
+ - The path to the |compass| executable. The name and file path of the
125
+ executable depend on your operating system.
126
+
127
+ - The ``--import-connections`` option set to the destination of the file
128
+ containing favorite connections.
129
+
130
+ Your operation should resemble the following prototype:
131
+
132
+ .. code-block:: sh
133
+
134
+ <path-to-Compass-executable> --import-connections=<filename>
135
+
136
+ Example
137
+ ~~~~~~~
138
+
139
+ The following example imports favorite |compass-short| connections from
140
+ a file with the path ``/tmp/compass-connections/favorites.json``.
141
+
142
+ Run the following command in the folder containing your MongoDB Compass
143
+ executable:
144
+
145
+ .. code-block:: sh
146
+
147
+ ./MongoDB\ Compass --import-connections=/tmp/compass-connections/favorites.json
148
+
149
+ .. note::
150
+
151
+ The name and file path of the executable depend on your operating
152
+ system. The preceding command is for macOS.
153
+
154
+ Results
155
+ ```````
156
+
157
+ After you run the import command, you will see this output:
158
+
159
+ .. code-block:: sh
160
+ :copyable: false
161
+
162
+ Importing connections from "/tmp/compass-connections/favorites.json" (without passphrase)
163
+
164
+ MongoDB Compass starts and you will see the imported connections under
165
+ :guilabel:`Saved Connections` on the Connect screen.
0 commit comments