MongoDB Download
MONGODB provides pre-compiled binaries for both 32-bit and 64-bit systems, which you can download from MongoDB website, MongoDB precompiled binary package: Http://www.mongodb.org/downloads
Note: Windows XP systems are no longer supported after the MongoDB2.2 version.
- MongoDB for Windows 64-bit is suitable for 64-bit Windows Server R2, Windows 7, and the latest version of the Window system.
- MongoDB for Windows 32-bit is suitable for 32-bit Window systems and the latest Windows Vista. MongoDB databases on 32-bit systems have a maximum of 2GB.
- MongoDB for Windows 64-bit Legacy is suitable for 64-bit Windows Vista, Windows Server 2003, and Windows Server 2008.
Download the 32-bit or 64-bit. msi file based on your system, double-click the file after downloading, and install it as prompted.
During the installation process, you can set up your installation directory by tapping the custom button.
Create Data Catalog
MongoDB stores the data directory in the DB directory. However, this data directory is not actively created, and we need to create it after the installation is complete. Note that the data directory should be placed under the root directory (e.g. C: \ or D:\. , etc.).
In this tutorial, we've installed MongoDB on the C: disk, now let's create a directory of data and then create the DB directory in the data directory.
C:\>CD c:c:\>mkdir datac:\>cd datac:\data>mkdir dbc:\data>cd dbc:\data\db>
You can also create these directories through the Windows Explorer, not necessarily through the command line.
Run MongoDB server under command line
In order to run the MongoDB server from the command prompt, you must execute the Mongod.exe file from the bin directory of the MongoDB directory.
Mongod.exe--dbpath c:\data\db
If the execution succeeds, the following information is output:
2015-09-25t15:54:09.212+0800 I CONTROL Hotfix KB2731284 or later update is notinstalled, would zero-out data files2015- 09-25t15:54:09.229+0800 i JOURNAL [Initandlisten] JOURNAL dir=c:\data\db\journal2015-09-25t15:54:09.237+0800 i JOURNAL [Initandlisten] recover:no JOURNAL files present, no recovery needed2015-09-25t15:54:09.290+0800 I journal< C3/>[durability] Durability thread started2015-09-25t15:54:09.294+0800 I CONTROL [Initandlisten] MongoDB starting : pid=2488 port=27017 dbpath=c:\data\db 64-bit host=win-1vonbjoce882015-09-25t15:54:09.296+0800 I CONTROL [ Initandlisten] targetminos:windows 7/windows Server r22015-09-25t15:54:09.298+0800 I CONTROL [Initandlisten] DB version v3.0.6 ...
To run the MongoDB server as a Windows service
Note that you must have administrative privileges to run the following command. Execute the following command to run the MongoDB server as a Windows service:
Mongod.exe--bind_ip youripadress--logpath "C:\data\dbConf\mongodb.log"--logappend--dbpath "C:\data\db"--port Yourportnumber--servicename "Yourservicename"--servicedisplayname "Yourservicename"--install
The following table describes the parameters for MongoDB startup:
Parameter description
--bind_ip |
Bind service IP, if bind 127.0.0.1, can only native access, do not specify default local all IP |
--logpath |
Specify the MongoDB log file, note that the specified file is not a directory |
--logappend |
Write a log using an Append method |
--dbpath |
Specify the database path |
--port |
Specifying the service port number, default port 27017 |
--servicename |
Specify the service name |
--servicedisplaynam |
Specifies the service name that is executed when there are multiple MongoDB services. |
--install |
Specifies the installation as a Windows service. |
MongoDB Background Management Shell
If you need to get into MongoDB background management, you need to open the bin directory of the MongoDB directory first, then execute the mongo.exe file, MongoDB Shell is the interactive JavaScript shell that comes with MongoDB, An interactive environment that is used to manipulate and manage MongoDB.
When you enter MongoDB background, it is linked to the test document (database) by default:
> Mongomongodb Shell version:3.0.6connecting to:test ...
Since it is a JavaScript shell, you can run some simple arithmetic operations:
> 2 + 24>
The db command is used to view the document (database) of the current operation:
> dbtest>
Insert some simple records and look for it:
> Db.codingkit.insert ({x:10}) Writeresult ({"ninserted": 1}) > Db.codingkit.find () {"_id": ObjectId (" 5604FF74A274A611B0C990AA ")," X ": Ten}>
The first command inserts the number 10 into the X field of the Codingkit collection.
Reprinted from: Windows Platform installation MongoDB
Windows under MongoDB installation