Install MongoDB Community Edition on WindowsВ¶
Use this tutorial to install MongoDB Community Edition on Windows systems.
Starting in version 2.2, MongoDB does not support Windows XP. Please use a more recent version of Windows to use more recent releases of MongoDB.
If you are running any edition of Windows Server 2008 R2 or Windows 7, please install a hotfix to resolve an issue with memory mapped files on Windows.
RequirementsВ¶
MongoDB Community Edition requires Windows Server 2008 R2, Windows Vista, or later. The .msi installer includes all other software dependencies and will automatically upgrade any older version of MongoDB installed using an .msi file.
Get MongoDB Community EditionВ¶
To install a different version of MongoDB, please refer to that version’s documentation. For example, see version 3.2.
Determine which MongoDB build you need.В¶
The following MongoDB builds are available for Windows:
MongoDB for Windows 64-bit runs only on Windows Server 2008 R2, Windows 7 64-bit, and newer versions of Windows. This build takes advantage of recent enhancements to the Windows Platform and cannot operate on older versions of Windows.
MongoDB for Windows 64-bit Legacy runs on Windows Vista, and Windows Server 2008 and does not include recent performance enhancements.
To find which version of Windows you are running, enter the following commands in the Command Prompt or Powershell :
Download MongoDB for Windows.В¶
Download the latest production release of MongoDB from the MongoDB downloads page. Ensure you download the correct version of MongoDB for your Windows system. The 64-bit versions of MongoDB do not work with 32-bit Windows.
Install MongoDB Community EditionВ¶
Interactive InstallationВ¶
Install MongoDB for Windows.В¶
In Windows Explorer, locate the downloaded MongoDB .msi file, which typically is located in the default Downloads folder. Double-click the .msi file. A set of screens will appear to guide you through the installation process.
You may specify an installation directory if you choose the “Custom” installation option.
These instructions assume that you have installed MongoDB to C:\Program Files\MongoDB\Server\3.4\ .
MongoDB is self-contained and does not have any other system dependencies. You can run MongoDB from any folder you choose. You may install MongoDB in any folder (e.g. D:\test\mongodb ).
Unattended InstallationВ¶
You may install MongoDB Community unattended on Windows from the command line using msiexec.exe .
Open an Administrator command prompt.В¶
Press the Win key, type cmd.exe , and press Ctrl + Shift + Enter to run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
Install MongoDB for Windows.В¶
Change to the directory containing the .msi installation binary of your choice and invoke:
You can specify the installation location for the executable by modifying the INSTALLLOCATION value.
By default, this method installs all MongoDB binaries. To install specific MongoDB component sets, you can specify them in the ADDLOCAL argument using a comma-separated list including one or more of the following component sets:
For instance, to install only the MongoDB utilities, invoke:
Run MongoDB Community EditionВ¶
Do not make mongod.exe visible on public networks without running in “Secure Mode” with the auth setting. MongoDB is designed to be run in trusted environments, and the database does not enable “Secure Mode” by default.
Set up the MongoDB environment.В¶
MongoDB requires a data directory to store all data. MongoDB’s default data directory path is the absolute path \data\db on the drive from which you start MongoDB. Create this folder by running the following command in a Command Prompt :
You can specify an alternate path for data files using the --dbpath option to mongod.exe , for example:
If your path includes spaces, enclose the entire path in double quotes, for example:
You may also specify the dbpath in a configuration file .
Start MongoDB.В¶
To start MongoDB, run mongod.exe . For example, from the Command Prompt :
This starts the main MongoDB database process. The waiting for connections message in the console output indicates that the mongod.exe process is running successfully.
Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features” of C:\Program Files\MongoDB\Server\3.4\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 see the Security Documentation .
Connect to MongoDB.В¶
To connect to MongoDB through the mongo.exe shell, open another Command Prompt .
If you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.
Begin using MongoDB.В¶
To help you start using MongoDB, MongoDB provides Getting Started Guides in various driver editions. See Getting Started for the available editions.
Before deploying MongoDB in a production environment, consider the Production Notes document.
Later, to stop MongoDB, press Control+C in the terminal where the mongod instance is running.
Configure a Windows Service for MongoDB Community EditionВ¶
Open an Administrator command prompt.В¶
Press the Win key, type cmd.exe , and press Ctrl + Shift + Enter to run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
Create directories.В¶
Create directories for your database and log files:
Create a configuration file.В¶
Create a configuration file. The file must set systemLog.path . Include additional configuration options as appropriate.
For example, create a file at C:\Program Files\MongoDB\Server\3.4\mongod.cfg that specifies both systemLog.path and storage.dbPath :
Install the MongoDB service.В¶
Run all of the following commands in Command Prompt with “Administrative Privileges”.
Install the MongoDB service by starting mongod.exe with the --install option and the -config option to specify the previously created configuration file.
To use an alternate dbpath , specify the path in the configuration file (e.g. C:\mongodb\mongod.cfg ) or on the command line with the --dbpath option.
If needed, you can install services for multiple instances of mongod.exe or mongos.exe . Install each service with a unique --serviceName and --serviceDisplayName . Use multiple instances only when sufficient system resources exist and your system design requires it.
Start the MongoDB service.В¶
Stop or remove the MongoDB service as needed.В¶
To stop the MongoDB service use the following command:
To remove the MongoDB service use the following command:
Manually Create a Windows Service for MongoDB Community EditionВ¶
You can set up the MongoDB server as a Windows Service that starts automatically at boot time.
The following procedure assumes you have installed MongoDB Community using the .msi installer with the path C:\Program Files\MongoDB\Server\3.4\ .
If you have installed in an alternative directory, you will need to adjust the paths as appropriate.
Open an Administrator command prompt.В¶
Press the Win key, type cmd.exe , and press Ctrl + Shift + Enter to run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
Create directories.В¶
Create directories for your database and log files:
Create a configuration file.В¶
Create a configuration file. The file must set systemLog.path . Include additional configuration options as appropriate.
For example, create a file at C:\Program Files\MongoDB\Server\3.4\mongod.cfg that specifies both systemLog.path and storage.dbPath :
Create the MongoDB service.В¶
Create the MongoDB service.
sc.exe requires a space between “=” and the configuration values (eg “binPath= “), and a “" to escape double quotes.
If successfully created, the following log message will display:
Start the MongoDB service.В¶
Stop or remove the MongoDB service as needed.В¶
To stop the MongoDB service, use the following command:
To remove the MongoDB service, first stop the service and then run the following command:
Additional ResourcesВ¶
© MongoDB, Inc 2008-present. MongoDB, Mongo, and the leaf logo are registered trademarks of MongoDB, Inc.
Комментариев нет:
Отправить комментарий