MongoDB Download
- Login to MongoDB official website: www.mongodb.org; Click the "Download MongoDB" button to enter the interface shown below
- Select the target operating system and its version, for example, the 64-bit Windows Server 2008R2 is selected here
- Download. Click the Download button to complete the download of the MSI file.
Installation
- Directly double-click the MSI installation file to start the installation. After the installation is complete, you can see the following directory structure under the installation path:
- Here you can see some common files:
Mongo.exe |
Client programs |
Mongod.exe |
a server-side program that starts by running the program MongoDB Service |
- Now the direct run of the Mongod.exe will be a flash back, need to make some necessary configuration.
Configuration
- Set Environment variables
Set the MongoDB bin file to the path of the environment variable: C:\Program files\mongodb\server\3.0\bin. This can be done directly in the console by typing MONGO, Mongod and other commands.
- Create data directory
MongoDB default attempts to use the \data\db directory of the current drive as its data directory (for example: Run Mongod.exe under C:), and by default, the directory is not created automatically. So it's going to come back. The
can of course create a data directory anywhere in the system, except in this case, you need to specify the path when you start MongoDB. Use the following command:
> Mongod--dbpath C:\mongodb\data\db
So you can change the default data directory.
- to install MongoDB as a Windows service
by installing MongoDB as a Windows service, you can avoid manually starting Mongod.exe each time you use it.
Follow these steps:
Run cmd as an administrator. Enter Mongod--dbpath c:\data\db--logpath c:\data\mongo.log-install
--dbpath |
This parameter specifies the location of the data directory, where the default location is used, which can actually be any other location |
--logpath |
This parameter specifies the location and file name of the database log file, which can be any file name in any location |
Looking at the Windows service, we've been able to see a service called MongoDB.
It is not started, but is set to auto-start type, the next time the system starts automatically, of course, this will not wait until the next boot, manually start it.
Check
MongoDB Default connection Port 27017, after starting the service, open http://localhost:27017, return the prompt, indicating that the installation was successful.
In the console, enter the command MONGO as shown in
In this case, MongoDB has been installed successfully!
Under Windows MongoDB Environment Building