Skip to content

Commit d1af11c

Browse files
author
Ed Costello
committed
DOCS-527 edit, reformat, add dbshell and environment variables
1 parent e5c2cf3 commit d1af11c

File tree

1 file changed

+96
-26
lines changed

1 file changed

+96
-26
lines changed

source/reference/mongo.txt

Lines changed: 96 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,29 @@
11
.. _mongo:
22

3+
.. meta::
4+
:description: The mongo shell man page
5+
:keywords: man page, mongo, javascript, shell
6+
37
.. default-domain:: mongodb
48

59
================
6-
:program:`mongo`
10+
mongo
711
================
812

913
Synopsis
1014
--------
1115

16+
.. describe:: mongo [--shell] [--nodb] [--norc] [--quiet] [--port <port>] [--host <host>] [--eval <JavaScript>] [-u <username>] [--username <username>] [-p <password>] [--password <password>] [--help] [-h] [--version] [--verbose] [--ipv6] [database] [file.js]
17+
18+
Description
19+
-----------
20+
1221
:program:`mongo` is an interactive JavaScript shell interface to
13-
MongoDB. :program:`mongo` provides a powerful administrative interface
14-
for systems administrators as well as an way to test queries and
22+
MongoDB. :program:`mongo` provides a powerful interface
23+
for systems administrators as well as a way to test queries and
1524
operations directly with the database. To increase the flexibility of
1625
:program:`mongo`, the shell provides a fully functional JavaScript
17-
environment. This manual page, addresses the basic invocation of the
26+
environment. This document addresses the basic invocation of the
1827
:program:`mongo` shell and an overview of its usage.
1928

2029
.. STUB -- This manual contains more extensive documentation of :program:`mongo` in the ":doc:`/mongo`" document.
@@ -26,84 +35,84 @@ Options
2635

2736
.. program:: mongo
2837

29-
.. option:: --shell
38+
.. cmdoption:: --shell
3039

3140
If you invoke the :program:`mongo` and specify a :term:`JavaScript`
3241
file as an argument, or ":option:`mongo --eval`" the
33-
:option:`--shell` provides the user with a shell prompt after the
42+
:option:`--shell` option provides the user with a shell prompt after the
3443
file finishes executing.
3544

36-
.. option:: --nodb
45+
.. cmdoption:: --nodb
3746

3847
Use this option to prevent the shell from connecting to any
3948
database instance.
4049

41-
.. option:: --norc
50+
.. cmdoption:: --norc
4251

4352
By default :program:`mongo` runs the ``~/.mongorc.js`` file when it
4453
starts. Use this option to prevent the shell from sourcing this
4554
file on start up.
4655

47-
.. option:: --quiet
56+
.. cmdoption:: --quiet
4857

4958
Silences output from the shell during the connection process.
5059

51-
.. option:: --port <PORT>
60+
.. cmdoption:: --port <PORT>
5261

5362
Specify the port where the :program:`mongod` or :program:`mongos`
5463
instance is listening. Unless specified :program:`mongo` connects
5564
to :program:`mongod` instances on port 27017, which is the default
5665
:program:`mongod` port.
5766

58-
.. option:: --host <HOSTNAME>
67+
.. cmdoption:: --host <HOSTNAME>
5968

6069
Specific the host where the :program:`mongod` or :program:`mongos` is running to
6170
connect to as ``<HOSTNAME>``. By default :program:`mongo` will attempt
6271
to connect to MongoDB process running on the localhost.
6372

64-
.. option:: --eval <JAVASCRIPT>
73+
.. cmdoption:: --eval <JAVASCRIPT>
6574

6675
Evaluates a JavaScript specified as an argument to this
6776
option. :program:`mongo` does not load its own environment when evaluating
68-
code: as a result many convinces of the shell environment are not
77+
code: as a result many options of the shell environment are not
6978
available.
7079

71-
.. option:: --username <USERNAME>, -u <USERNAME>
80+
.. cmdoption:: --username <USERNAME>, -u <USERNAME>
7281

7382
Specify a username to authenticate to the MongoDB instance, if your
7483
database requires authentication. Use in conjunction with the
7584
:option:`mongo --password` option to supply a password.
7685

77-
.. option:: --password <password>, -p <password>
86+
.. cmdoption:: --password <password>, -p <password>
7887

7988
Specify a password to authenticate to the MongoDB instance, if your
8089
database requires authentication. Use in conjunction with the
8190
:option:`mongo --username` option to supply a username. If you
8291
specify a :option:`--username <mongo --username>` without the
83-
:option:`--password` option, :program:`mongo` will prompt for a
92+
:option:`mongo --password` option, :program:`mongo` will prompt for a
8493
password interactively.
8594

86-
.. option:: --help, -h
95+
.. cmdoption:: --help, -h
8796

8897
Returns a basic help and usage text.
8998

90-
.. option:: --version
99+
.. cmdoption:: --version
91100

92101
Returns the version of the shell.
93102

94-
.. option:: --verbose
103+
.. cmdoption:: --verbose
95104

96105
Increases the verbosity of the output of the shell during the
97106
connection process.
98107

99-
.. option:: --ipv6
108+
.. cmdoption:: --ipv6
100109

101110
Enables IPv6 support that allows :program:`mongo` to connect
102111
to the MongoDB instance using an IPv6 network. All MongoDB programs
103112
and processes, including :program:`mongo`, disable IPv6
104113
support by default.
105114

106-
.. option:: <db address>
115+
.. cmdoption:: <db address>
107116

108117
Specify the "database address" of the database to connect to. For
109118
example: ::
@@ -122,15 +131,13 @@ Options
122131

123132
.. _mongo-shell-file:
124133

125-
.. option:: <file.js>
134+
.. cmdoption:: <file.js>
126135

127136
Optionally, specify a JavaScript file as the final argument to the
128137
shell. The shell will run the file and then exit. Use the
129-
:option:`mongo --shell` to return to a shell after the file
138+
:option:`mongo --shell` option to return to a shell after the file
130139
finishes running.
131140

132-
This should be the last address
133-
134141
Usage
135142
-----
136143

@@ -156,7 +163,7 @@ values for your situation and substitute or omit the :option:`--port`
156163
as needed.
157164

158165
To execute a JavaScript file without evaluating the ``~/.mongorc.js``
159-
file before starting a sell session, use the following form:
166+
file before starting a shell session, use the following form:
160167

161168
.. code-block:: sh
162169

@@ -172,3 +179,66 @@ the :option:`--eval <mongo --eval>` option, use the following form:
172179
Note the use of single quotes (e.g. ``'``) to enclose the JavaScript,
173180
as well as the additional JavaScript required to generate this
174181
output.
182+
183+
Files
184+
-----
185+
186+
:file:`~/.dbshell`
187+
188+
:program:`mongo` maintains a history of commands in the `.dbshell`
189+
file.
190+
191+
.. note:
192+
193+
Authentication commands (such as :dbcommand:`authenticate`,
194+
:method:`db.addUser()`) will not be saved in the history file.
195+
196+
.. warning:
197+
198+
Versions of Windows :command:`mongo.exe` earlier than 2.2.0
199+
will save the `.dbshell` file in the :command:`mongo.exe`
200+
working directory.
201+
202+
:file:`~/.mongorc.js`
203+
204+
:program:`mongo` will read `.mongorc.js` from the home directory
205+
of the user invoking :program:`mongo`.
206+
Specify the :option:`mongo --norc` option to disable
207+
reading `.mongorc.js`.
208+
209+
:file:`/tmp/mongo_edit{<time_t>}.js`
210+
211+
Created by :program:`mongo` when editing a file. If the file
212+
exists :program:`mongo` will append an integer from 1 to 10 to
213+
the time value to attempt to create a unique file.
214+
215+
:file:`%TEMP%\mongo_edit{<time_t>}.js`
216+
217+
Created by :command:`mongo.exe` on Windows when editing a file.
218+
If the file
219+
exists :program:`mongo` will append an integer from 1 to 10 to
220+
the time value to attempt to create a unique file.
221+
222+
Environment
223+
-----------
224+
225+
.. envvar:: EDITOR
226+
227+
Specify the path to an editor to use with the `edit` shell command.
228+
A JavaScript variable `EDITOR` will override the value of
229+
:envvar:`EDITOR`.
230+
231+
.. envvar:: HOME
232+
233+
Specify the path to the home directory where `.mongorc.js` will be
234+
read from and `.dbshell` will be written to.
235+
236+
.. envvar:: HOMEDRIVE
237+
238+
Specify the Windows path to the home directory where `.mongorc.js` will be
239+
read from and `.dbshell` will be written to.
240+
241+
.. envvar:: HOMEPATH
242+
243+
Specify the Windows path to the home directory where `.mongorc.js` will be
244+
read from and `.dbshell` will be written to.

0 commit comments

Comments
 (0)