@@ -12,41 +12,68 @@ This tutorial outlines the basic installation process for
12
12
tutorial provides a basic method for installing and running the
13
13
MongoDB server (i.e. ":program:`mongod.exe`") and associated tools.
14
14
15
- Downloading MongoDB for Windows
16
- -------------------------------
15
+ MongoDB for Windows
16
+ -------------------
17
17
18
- Download the latest production release of MongoDB. The various MongoDB
19
- binaries can be downloaded `here. <http://www.mongodb.org/downloads>`_
18
+ MongoDB for Windows is very similar to it MongoDB for other
19
+ platforms. MongoDB components work in the same way and with similar
20
+ parameters to MongoDB for other platforms. This tutorial will guide
21
+ you to install MongoDB on Windows through the :guilabel:`Command
22
+ Shell` and setting up MongoDB as a :guilabel:`Windows Service`.
23
+
24
+ Download MongoDB for Windows
25
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
26
+
27
+ Download the latest production release of MongoDB from `here. <http://www.mongodb.org/downloads>`_
20
28
21
29
.. note::
22
30
23
- Ensure you download the proper version of MongoDB for your version
24
- of Windows. The 64-bit version of MongoDB will not work in 32-bit
25
- version of Windows. You can find the version of your Windows system
26
- using this `guide. <http://windows.microsoft.com/en-US/windows7/find-out-32-or-64-bit>`_
31
+ Ensure you download the proper version of MongoDB for your
32
+ architecture of Windows. The 64-bit version of MongoDB will not
33
+ work in 32-bit Windows.
27
34
28
35
The 32-bit versions of MongoDB are suitable for testing and
29
- evaluation purposes but cannot use databases larger than 3GB.
36
+ evaluation purposes but cannot use databases larger than 2GB.
37
+
38
+ The architecture of your version of Windows can be found using this
39
+ command in the :guilabel:`Command Shell`
40
+
41
+ .. code-block:: powershell
42
+
43
+ wmic os get osarchitecture
30
44
31
- Once the download is complete, use Windows Explorer to find the
32
- MongoDB download file (typically in the default Downloads directory)
33
- and extract the archive to ``C:\`` by right clicking on the
34
- archive and selecting "Extract All" and browsing to: ``C:\``
45
+ In Windows Explorer, find the MongoDB download file, typically in the
46
+ default Downloads directory, and extract the archive to ``C:\`` by
47
+ right clicking on the archive and selecting :guilabel:`Extract All`
48
+ and browsing to: ``C:\``
35
49
36
50
.. note::
37
51
38
- The folder name will be in the format:
52
+ The folder name will be either:
53
+
54
+ .. code-block:: powershell
55
+
56
+ C:\mongodb-win32-i386-[version]
57
+
58
+ Or:
59
+
60
+ .. code-block:: powershell
61
+
62
+ C:\mongodb-win32-x86_64-[version]
39
63
40
- mongodb-win32-ARCH-VERSION
64
+ In both examples, replace ``[version]`` with the version of MongoDB
65
+ downloaded.
41
66
42
- where ARCH is the 32-bit/64-bit version of MongoDB and VERSION is
43
- the version of MongoDB
67
+ Set up the environment
68
+ ~~~~~~~~~~~~~~~~~~~~~~
44
69
45
- Start the Command Prompt (Start Menu -> All Programs -> Accessories ->
46
- Command Prompt) by right clicking and selecting 'Run as
47
- Administrator' from the popup menu. In the Command Prompt, run commands:
70
+ Start the :guilabel:`Command Shell` by selecting the :guilabel:`Start
71
+ Menu`, then :guilabel:`All Programs`, then :guilabel:`Accessories`,
72
+ then right click :guilabel:`Command Shell`, and select :guilable:'Run
73
+ as Administrator' from the popup menu. In the :guilabel:`Command Shell`,
74
+ issue the following commands:
48
75
49
- .. code-block:: sh
76
+ .. code-block:: powershell
50
77
51
78
cd \
52
79
rename C:\mongodb-win32-* C:\mongodb
@@ -58,86 +85,144 @@ Administrator' from the popup menu. In the Command Prompt, run commands:
58
85
may install MongoDB in a different directory such as:
59
86
``D:\test\mongodb``
60
87
61
- Creating data Folder
62
- ~~~~~~~~~~~~~~~~~~~~
88
+ By default, MongoDB requires a data folder to store files. By default
89
+ this is: ``C:\data\db``. Create this folder in ``C:\`` in the
90
+ :guilabel:`Command Shell` by issuing the following commands
63
91
64
- By default, MongoDB uses ``C:\data\db`` to write and store data
65
- files. Create this folder in C:\ in the Command Prompt using the
66
- following commands:
67
-
68
- .. code-block:: sh
92
+ .. code-block:: powershell
69
93
70
94
mkdir data
71
95
mkdir data\db
72
96
73
- If this folder does not exist, MongoDB will not start.
74
-
75
97
.. note::
76
98
77
99
You can specify an alternate path for data\db folder using the
78
100
:option:`--dbpath <mongod --dbpath>` option to
79
101
:program:`mongod`. To start mongod.exe with another file path, use
80
- the command: ``C:\mongodb\bin\mongod.exe --dbpath
81
- d:\test\mongodb\data``
102
+ the command:
103
+
104
+ .. code-block:: powershell
82
105
106
+ C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data
83
107
84
- Starting MongoDB
85
- ~~~~~~~~~~~~~~~~
86
108
87
- To start MongoDB, execute from the Command Prompt:
109
+ Start MongoDB for Windows
110
+ ~~~~~~~~~~~~~~~~~~~~~~~~~
88
111
89
- .. code-block:: sh
112
+ To start MongoDB, execute from the :guilabel:`Command Shell`:
113
+
114
+ .. code-block:: powershell
90
115
91
116
C:\mongodb\bin\mongod.exe
92
117
93
- This will start the main MongoDB database process. To connect using
94
- the ``mongo.exe`` open another Command Prompt and execute:
118
+ This will start the main MongoDB database process.
119
+
120
+ .. note::
121
+
122
+ Depending on the security level of your system, Windows will issue
123
+ a :guilabel:`Security Alert` dialog box about blocking "some
124
+ features" of ``C:\\mongodb\bin\mongod.exe`` from communicating on
125
+ networks. All users should select ``Private Networks, such as my
126
+ home or work network`` and click ``Allow access``. For additional
127
+ information on security and MongoDB, please read the
128
+ :wiki:`Security and Authentication <Security+and+Authentication>`
129
+ wiki page.
130
+
131
+ .. warning::
132
+
133
+ Do not make :program:`mongod.exe` accessible to public networks
134
+ without authentication (i.e. :setting:`auth`) on a public
135
+ network. MongDB is designed to work within secured networks and
136
+ will accept connections without authentication.
137
+
138
+ To connect to MongoDB using the :program:`mongo.exe`, open another
139
+ :guilabel:`Command Shell` and issue command:
95
140
96
- .. code-block:: sh
141
+ .. code-block:: powershell
97
142
98
143
C:\mongodb\bin\mongo.exe
99
144
100
145
.. note::
101
146
102
147
Executing command: ``start C:\mongodb\bin\mongo.exe`` will
103
- automatically start MongoDB in a separate Command Prompt .
148
+ automatically start MongoDB in a separate :guilabel:` Command Shell` .
104
149
105
150
This will connect to the database running on the localhost interface
106
- and port 27017 by default. At the :program:`mongo.exe` prompt, issue
107
- the following two commands to insert a record in the " test"
108
- :term:`collection` of the ( default) " test" database and then retrieve
151
+ and port `` 27017`` by default. At the :program:`mongo.exe` prompt, issue
152
+ the following two commands to insert a record in the `` test``
153
+ :term:`collection` of the default `` test`` database and then retrieve
109
154
that record:
110
155
111
156
.. code-block:: javascript
112
157
113
158
> db.test.save( { a: 1 } )
114
159
> db.test.find()
115
160
116
- Additional MongoDB guides to help you get started:
161
+ .. seealso:: ":program:`mongo`" and ":doc:`/reference/javascript`"
162
+
163
+
164
+ MongoDB as Windows Service
165
+ --------------------------
166
+
167
+ .. versionadded:: 2.1.1
168
+
169
+ Setup MongoDB to be a :guilabel:`Windows Service`, starting
170
+ automatically with each reboot.
171
+
172
+ Configure Windows Service Options
173
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
174
+
175
+ You must specify two options when running MongoDB as a Windows
176
+ Service: a directory for the log output and a :doc:`configuration file
177
+ </reference/configuration-options>`.
178
+
179
+ #. Create a specific directory for MongoDB log files:
180
+
181
+ .. code-block:: powershell
182
+
183
+ mkdir C:\mongodb\log
184
+
185
+ #. Create a configuration file for the logpath option for MongoDB in
186
+ the :guilabel:`Command Shell` by issuing this command:
187
+
188
+ .. code-block:: powershell
189
+
190
+ echo logpath=C:\mongodb\log > C:\mongodb\mongodb.cfg
191
+
192
+
193
+ To Install and Run the MongoDB Service
194
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
195
+
196
+ Run all of the following commands in :guilabel:`Command Shell` with
197
+ "Administrative Privileges:"
198
+
199
+ #. To install the MongoDB service:
200
+
201
+ .. code-block:: powershell
202
+
203
+ C:\mongodb\bin\mongod.exe --config C:\mongodb\mongodb.cfg --install
204
+
205
+ #. To run the MongoDB Service:
117
206
118
- .. Documentation for getting started with MongoDB:
207
+ .. code-block:: powershell
119
208
120
- .. - :doc:`/getting-started`
121
- .. STUB - :doc:`/tutorial/insert-test-data-into-a-mongodb-database`
209
+ net start MongoDB
122
210
211
+ To Stop or Remove the MongoDB Service
212
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
123
213
214
+ #. To stop MongoDB Service:
124
215
125
- .. how do we use this??
126
- :program:`mongod.exe`
127
- :program:`mongo.exe`
128
- :program:`mongos.exe`
216
+ .. code-block:: powershell
129
217
130
- Production Use
131
- ~~~~~~~~~~~~~~
218
+ net stop MongoDB
132
219
133
- If you're deploying MongoDB on a Windows server for production use,
134
- you may want to use the [whatever you call it].
220
+ #. To remove MongoDB Service:
135
221
136
- Do this...
222
+ .. code-block:: powershell
137
223
138
- .. code-block:: sh
224
+ C:\mongodb\bin\mongod.exe --remove
139
225
140
- TODO simple service example.
141
226
142
227
143
228
0 commit comments