diff --git a/source/installation.txt b/source/installation.txt index f87be61f943..2979bd40dd0 100644 --- a/source/installation.txt +++ b/source/installation.txt @@ -18,8 +18,7 @@ and packages. Choose your platform below: tutorial/install-mongodb-on-debian-or-ubuntu-linux tutorial/install-mongodb-on-linux tutorial/install-mongodb-on-os-x - -- :wiki:`Windows ` + tutorial/install-mongodb-on-windows Release Notes ------------- diff --git a/source/tutorial.txt b/source/tutorial.txt index befa554687b..85712c93e98 100644 --- a/source/tutorial.txt +++ b/source/tutorial.txt @@ -58,6 +58,7 @@ Installation tutorial/install-mongodb-on-linux tutorial/install-mongodb-on-os-x tutorial/install-mongodb-on-redhat-centos-or-fedora-linux + tutorial/install-mongodb-on-windows .. index:: tutorials; application development .. index:: application tutorials diff --git a/source/tutorial/install-mongodb-on-windows.txt b/source/tutorial/install-mongodb-on-windows.txt new file mode 100644 index 00000000000..9ed49d123b5 --- /dev/null +++ b/source/tutorial/install-mongodb-on-windows.txt @@ -0,0 +1,228 @@ +========================== +Install MongoDB on Windows +========================== + +.. default-domain:: mongodb + +Synopsis +-------- + +This tutorial outlines the basic installation process for +:term:`MongoDB` on Microsoft Windows systems. This +tutorial provides a basic method for installing and running the +MongoDB server (i.e. ":program:`mongod.exe`") and associated tools. + +MongoDB for Windows +------------------- + +MongoDB for Windows is very similar to it MongoDB for other +platforms. MongoDB components work in the same way and with similar +parameters to MongoDB for other platforms. This tutorial will guide +you to install MongoDB on Windows through the :guilabel:`Command +Shell` and setting up MongoDB as a :guilabel:`Windows Service`. + +Download MongoDB for Windows +~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Download the latest production release of MongoDB from `here. `_ + +.. note:: + + Ensure you download the proper version of MongoDB for your + architecture of Windows. The 64-bit version of MongoDB will not + work in 32-bit Windows. + + The 32-bit versions of MongoDB are suitable for testing and + evaluation purposes but cannot use databases larger than 2GB. + + The architecture of your version of Windows can be found using this + command in the :guilabel:`Command Shell` + + .. code-block:: powershell + + wmic os get osarchitecture + +In Windows Explorer, find the MongoDB download file, typically in the +default Downloads directory, and extract the archive to ``C:\`` by +right clicking on the archive and selecting :guilabel:`Extract All` +and browsing to: ``C:\`` + +.. note:: + + The folder name will be either: + + .. code-block:: powershell + + C:\mongodb-win32-i386-[version] + + Or: + + .. code-block:: powershell + + C:\mongodb-win32-x86_64-[version] + + In both examples, replace ``[version]`` with the version of MongoDB + downloaded. + +Set up the environment +~~~~~~~~~~~~~~~~~~~~~~ + +Start the :guilabel:`Command Shell` by selecting the :guilabel:`Start +Menu`, then :guilabel:`All Programs`, then :guilabel:`Accessories`, +then right click :guilabel:`Command Shell`, and select :guilable:'Run +as Administrator' from the popup menu. In the :guilabel:`Command Shell`, +issue the following commands: + +.. code-block:: powershell + + cd \ + rename C:\mongodb-win32-* C:\mongodb + +.. note:: + + MongoDB is self-contained and do not have any other system + dependencies. You can run MongoDB from any folder you choose. One + may install MongoDB in a different directory such as: + ``D:\test\mongodb`` + +By default, MongoDB requires a data folder to store files. By default +this is: ``C:\data\db``. Create this folder in ``C:\`` in the +:guilabel:`Command Shell` by issuing the following commands + +.. code-block:: powershell + + mkdir data + mkdir data\db + +.. note:: + + You can specify an alternate path for data\db folder using the + :option:`--dbpath ` option to + :program:`mongod`. To start mongod.exe with another file path, use + the command: + + .. code-block:: powershell + + C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data + + +Start MongoDB for Windows +~~~~~~~~~~~~~~~~~~~~~~~~~ + +To start MongoDB, execute from the :guilabel:`Command Shell`: + +.. code-block:: powershell + + C:\mongodb\bin\mongod.exe + +This will start the main MongoDB database process. + +.. note:: + + Depending on the security level of your system, Windows will issue + a :guilabel:`Security Alert` dialog box about blocking "some + features" of ``C:\\mongodb\bin\mongod.exe`` from communicating on + networks. All users should select ``Private Networks, such as my + home or work network`` and click ``Allow access``. For additional + information on security and MongoDB, please read the + :wiki:`Security and Authentication ` + wiki page. + +.. warning:: + + Do not make :program:`mongod.exe` accessible to public networks + without authentication (i.e. :setting:`auth`) on a public + network. MongDB is designed to work within secured networks and + will accept connections without authentication. + +To connect to MongoDB using the :program:`mongo.exe`, open another +:guilabel:`Command Shell` and issue command: + +.. code-block:: powershell + + C:\mongodb\bin\mongo.exe + +.. note:: + + Executing command: ``start C:\mongodb\bin\mongo.exe`` will + automatically start MongoDB in a separate :guilabel:`Command Shell`. + +This will connect to the database running on the localhost interface +and port ``27017`` by default. At the :program:`mongo.exe` prompt, issue +the following two commands to insert a record in the ``test`` +:term:`collection` of the default ``test`` database and then retrieve +that record: + +.. code-block:: javascript + + > db.test.save( { a: 1 } ) + > db.test.find() + +.. seealso:: ":program:`mongo`" and ":doc:`/reference/javascript`" + + +MongoDB as Windows Service +-------------------------- + +.. versionadded:: 2.1.1 + +Setup MongoDB to be a :guilabel:`Windows Service`, starting +automatically with each reboot. + +Configure Windows Service Options +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +You must specify two options when running MongoDB as a Windows +Service: a directory for the log output and a :doc:`configuration file +`. + +#. Create a specific directory for MongoDB log files: + + .. code-block:: powershell + + mkdir C:\mongodb\log + +#. Create a configuration file for the logpath option for MongoDB in + the :guilabel:`Command Shell` by issuing this command: + + .. code-block:: powershell + + echo logpath=C:\mongodb\log > C:\mongodb\mongodb.cfg + + +To Install and Run the MongoDB Service +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +Run all of the following commands in :guilabel:`Command Shell` with +"Administrative Privileges:" + +#. To install the MongoDB service: + + .. code-block:: powershell + + C:\mongodb\bin\mongod.exe --config C:\mongodb\mongodb.cfg --install + +#. To run the MongoDB Service: + + .. code-block:: powershell + + net start MongoDB + +To Stop or Remove the MongoDB Service +~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +#. To stop MongoDB Service: + + .. code-block:: powershell + + net stop MongoDB + +#. To remove MongoDB Service: + + .. code-block:: powershell + + C:\mongodb\bin\mongod.exe --remove + + + +