|
| 1 | +========================== |
| 2 | +Install MongoDB on Windows |
| 3 | +========================== |
| 4 | + |
| 5 | +.. default-domain:: mongodb |
| 6 | + |
| 7 | +Synopsis |
| 8 | +-------- |
| 9 | + |
| 10 | +This tutorial outlines the basic installation process for |
| 11 | +:term:`MongoDB` on Microsoft Windows systems. This |
| 12 | +tutorial provides a basic method for installing and running the |
| 13 | +MongoDB server (i.e. ":program:`mongod.exe`") and associated tools. |
| 14 | + |
| 15 | +Downloading MongoDB for Windows |
| 16 | +------------------------------- |
| 17 | + |
| 18 | +Download the latest production release of MongoDB. The various MongoDB |
| 19 | +binaries can be downloaded `here. <http://www.mongodb.org/downloads>`_ |
| 20 | + |
| 21 | +.. note:: |
| 22 | + |
| 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>`_ |
| 27 | + |
| 28 | + The 32-bit versions of MongoDB are suitable for testing and |
| 29 | + evaluation purposes but cannot use databases larger than 3GB. |
| 30 | + |
| 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:\`` |
| 35 | + |
| 36 | +.. note:: |
| 37 | + |
| 38 | + The folder name will be in the format: |
| 39 | + |
| 40 | + mongodb-win32-ARCH-VERSION |
| 41 | + |
| 42 | + where ARCH is the 32-bit/64-bit version of MongoDB and VERSION is |
| 43 | + the version of MongoDB |
| 44 | + |
| 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: |
| 48 | + |
| 49 | +.. code-block:: sh |
| 50 | + |
| 51 | + cd \ |
| 52 | + rename C:\mongodb-win32-* C:\mongodb |
| 53 | + |
| 54 | +.. note:: |
| 55 | + |
| 56 | + MongoDB is self-contained and do not have any other system |
| 57 | + dependencies. You can run MongoDB from any folder you choose. One |
| 58 | + may install MongoDB in a different directory such as: |
| 59 | + ``D:\test\mongodb`` |
| 60 | + |
| 61 | +Creating data Folder |
| 62 | +~~~~~~~~~~~~~~~~~~~~ |
| 63 | + |
| 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 |
| 69 | + |
| 70 | + mkdir data |
| 71 | + mkdir data\db |
| 72 | + |
| 73 | +If this folder does not exist, MongoDB will not start. |
| 74 | + |
| 75 | +.. note:: |
| 76 | + |
| 77 | + You can specify an alternate path for data\db folder using the |
| 78 | + :option:`--dbpath <mongod --dbpath>` option to |
| 79 | + :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`` |
| 82 | + |
| 83 | + |
| 84 | +Starting MongoDB |
| 85 | +~~~~~~~~~~~~~~~~ |
| 86 | + |
| 87 | +To start MongoDB, execute from the Command Prompt: |
| 88 | + |
| 89 | +.. code-block:: sh |
| 90 | + |
| 91 | + C:\mongodb\bin\mongod.exe |
| 92 | + |
| 93 | +This will start the main MongoDB database process. To connect using |
| 94 | +the ``mongo.exe`` open another Command Prompt and execute: |
| 95 | + |
| 96 | +.. code-block:: sh |
| 97 | + |
| 98 | + C:\mongodb\bin\mongo.exe |
| 99 | + |
| 100 | +.. note:: |
| 101 | + |
| 102 | + Executing command: ``start C:\mongodb\bin\mongo.exe`` will |
| 103 | + automatically start MongoDB in a separate Command Prompt. |
| 104 | + |
| 105 | +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 |
| 109 | +that record: |
| 110 | + |
| 111 | +.. code-block:: javascript |
| 112 | + |
| 113 | + > db.test.save( { a: 1 } ) |
| 114 | + > db.test.find() |
| 115 | + |
| 116 | +Additional MongoDB guides to help you get started: |
| 117 | + |
| 118 | + .. Documentation for getting started with MongoDB: |
| 119 | + |
| 120 | + .. - :doc:`/getting-started` |
| 121 | + .. STUB - :doc:`/tutorial/insert-test-data-into-a-mongodb-database` |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | +.. how do we use this?? |
| 126 | +:program:`mongod.exe` |
| 127 | +:program:`mongo.exe` |
| 128 | +:program:`mongos.exe` |
| 129 | + |
| 130 | +Production Use |
| 131 | +~~~~~~~~~~~~~~ |
| 132 | + |
| 133 | +If you're deploying MongoDB on a Windows server for production use, |
| 134 | +you may want to use the [whatever you call it]. |
| 135 | + |
| 136 | +Do this... |
| 137 | + |
| 138 | +.. code-block:: sh |
| 139 | + |
| 140 | +TODO simple service example. |
| 141 | + |
| 142 | + |
| 143 | + |
0 commit comments