One, the installation of the Windows MongoDB
MONGODB provides pre-compiled binaries for both 32-bit and 64-bit systems, which you can download from MongoDB website, MongoDB precompiled binary package: https://www.mongodb.com/download-center#community
Note: Windows XP systems are no longer supported after the MongoDB 2.2 release. The latest version also has no installation files for the 32-bit system.
- 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 have MongoDB installed on C Drive, now let's create a directory of data and create a 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.
Ii. two ways to start MongoDB
1. Start at the 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.
C:\mongodb\bin--dbpath C:\data\db
If the execution succeeds, the following information is output:
2015-09-25t15:54:09.212+0800I CONTROLHotfixKB2731284OrLater updateIs NotInstalled,Would zero-OutData files2015-09-25t15:54:09.229+0800I JOURNAL[Initandlisten]Journal Dir=C:\data\db\journal2015-09-25t15:54:09.237+0800I JOURNAL[Initandlisten]Recover: NoJournal Files present, NoRecovery needed2015-09-25t15:54:09.290+0800I JOURNAL[Durability] DurabilityThread started2015-09-25t15:54:09.294+0800I CONTROL[Initandlisten] MongodbStarting:Pid=2488Port=27017DBPath=C:\data\db64-Bit host=WIN-1vonbjoce882015-09-25t15:54:09.296+0800I CONTROL[initandlisten] Targetminos: windows 7/ windows server 2008 R2< Span class= "lit" >2015-09-25t15 :54:09.298+ 0800 I CONTROL [initandlisten ] db version V3. 0.6 ...
Connect to MongoDB
We can run the Mongo.exe command in the command window to connect to MongoDB and execute the following command:
C:\mongodb\bin\mongo. EXE
Note: If you execute a command under the current file, you can configure the environment variable yourself
2. Start in a service mode
Configuring MongoDB Services
Admin Mode Open command-line window
Create a directory, and execute the following statement to create a directory of database and log files
mkdir c:\data\dbmkdir C:\data\log
Creating a configuration file
Create a configuration file. The file must have the Systemlog.path parameter set, including some additional configuration options that are better.
For example, create a configuration file that is located in C:\mongodb\mongod.cfg, where Systemlog.path and Storage.dbpath are specified. The specific configuration is as follows:
Systemlog: destination: file path: c:\data\log\mongod. Logstorage: dbPath: C:\data\db
Installing MongoDB Services
By executing Mongod.exe, using the--install option to install the service, use the--config option to specify the previously created configuration file.
C:\mongodb\bin\mongod. --"C:\mongodb\mongod.cfg"--install
To use an alternate dbpath, you can specify it through the--dbpath option in the configuration file (for example: C:\MONGODB\MONGOD.CFG) or on the command line.
If required, you can install services for multiple instances of Mongod.exe or Mongos.exe. You only need to specify a different instance name by using--servicename and--servicedisplayname. This should be done only if there is sufficient system resources and the design of the system.
Start MongoDB Service
Mongodb
Close MongoDB Service
Mongodb
Remove MongoDB Service
C:\mongodb\bin\mongod. --Remove
Install and start MongoDB under Windows