This tutorial describes how to install and run MongoDB on the Microsoft windowsmongodbserver (mongod.exe) platform as a Windows service by setting up MongoDB at the command prompt and summary process. Similar to operating on MongoDB on Windows, most components of MongoDB's other platforms share the same operating mode. Program
This tutorial describes how to install and run apsaradb for MongoDB on the Microsoft Windows mongodbserver (mongod.exe) platform. Similar to operating on MongoDB on Windows, most components of MongoDB's other platforms share the same operating mode. Program
Introduction ¶
This tutorial provides the installation and running methods on the Microsoft Windows mongodbserver (“mongod.exe ") platform by setting up MongoDB at the command prompt and summary process as a Windows service.
Similar to operating on MongoDB on Windows, most components of MongoDB's other platforms share the same operating mode.
Program Logging ¶
Download the MongoDB Windows Kernel ¶
Download the latest production version of MongoDB from the MongoDB download page.
Three Versions of MongoDB apply to Windows:
Change in version 2.2: MongoDB does not support Windows XP. Use the latest version of MongoDB for Windows.
Others
You can download the correct version of MongoDB Windows at any time. The 64-bit version of MongoDB works with 32-bit Windows.
MongoDB's 32-bit version is only applicable to testing and evaluation purposes and supports databases smaller than 2 GB.
You can find the architecture platform of your Windows version and run the following command in the command Prompt
Wmic OS get osarchitecture
Find the MongoDB download file in Windows Resource Manager, which is usually in the default download directory. Decompress the archive to C: \, right-click archive, select extract all, and browse to C :\.
Others
The folder name is:
C: \ mongodb-win32-i386-[version]
Or:
C: \ mongodb-win32-x86_64-[version]
In the two examples, replace the [version] of MongoDB to download
Set environment ¶
Select "start" to start the command prompt menu. Then, all programs are stored in the Hong Kong virtual host. Then, attach the attachment, right-click the command prompt, and select "Run" as the administrator. Run the following command on the VM:
Cd \
Move C: \ mongodb-win32-* C: \ mongodb
Others
MongoDB is self-contained and runs from any folder you choose without any other system dependencies. You started the investigation analyzer and can install any directory of MongoDB (for example, D: \ test \ mongodb)
MongoDB needs a data folder to store its files. The default DATA directory of MongoDB is C: \ DATA \ DB. Create a command prompt in this folder ". Run the following command sequence:
Md data
Md data \ db
Others
You can specify a backup path as \ DATA \ dbdbpathto set mongod.exe, as shown in the following example:
C: \ mongodb \ bin \ mongod.exe -- dbpath d: \ test \ mongodb \ data
If your path contains spaces, enclose the entire path in double quotation. For example:
C: \ mongodb \ bin \ mongod.exe -- dbpath "d: \ test \ mongo db data"
Start MongoDB Supervisor ¶
To start MongoDB, run the following command from the command prompt:
C: \ mongodb \ bin \ mongod.exe
This will start the process of the primary MongoDB database. The instance runs successfully during the waiting-to-connect message table mongod.exe output on the console.
Others
Based on the security level of your system, Windows will issue the security alarm "dialog box blocking" some functions "C: \ MongoDB's \ bin \ mongod.exe communication network. All users should select a private network, such as my home or work network, and click "Allow access ". For additional security and MongoDB information, please read the security and authentication wiki page
Warning
You do not need to allow mongod.exe to access the public network, instead of running in "security mode" (that is, authorization ). MongoDB is designed to run in a "trusted environment" and does not enable identity authentication or "security mode" in the database.
Connect the cmd.exe shell used by mongodb. Open another command prompt and issue the following command:
C: \ mongodb \ bin \ cmd.exe
Others
Run the command to start C: \ mongodb \ BIN \ mongo.exein the Shell Command Prompt window of cmd.exe, which is automatically started by a single user.
The ingress. exeshell is connected to mongod.exe to run the localhost interface. By default, port 27017 is used. At the end of the 19th century, execute the following two commands at the cmd.exe prompt to insert a default set of test databases for a record in the test and then retrieve the record:
> Db. test. save ({a: 1 })
> Db. test. find ()
See.
Mongo and Mongo. "IF you want to develop and use it. . NET Applications and virtual hosts. For more information, see the C # language center wiki page.
MongoDB as a Windows Service License ¶
In the new version 2.0.
The installed MongoDB is used as a Windows Service so that the database will be automatically started.
Others
Mongod.exeadds the runtime Windows support service 2.0133, and added support for running Windows Services in version 2.1.1 In cmd.exe.
System Configuration ¶
When running apsaradb for MongoDB as a Windows operating system, you must specify two options: log output path and configuration file modification.
Create a specific directory in the MongoDB log file:
Md C: \ mongodb \ log
Create a configuration file. Select MongoDB as the Log Path and run the following command at the command prompt:
Echo logpath = C: \ mongodb \ log \ mongo. log> C: \ mongodb \ mongod. cfg
Although these optional steps are optional, it is good to create a specific location log file and use the configuration file.
Others
Consider setting the logappend option. If this is not the case, mongod.exe will start when you Delete the existing log Content File.
Change in version 2.2: The default Log Path and logappend behavior change in version 2.2.
Install and run the MongoDB service ingress ¶
Run the following command and run "manage permissions" at the command prompt"
Services to install MongoDB:
C: \ mongodb \ bin \ mongod.exe -- config C: \ mongodb \ mongod. cfg -- install
Modify the path of the required mongod. cfg file. If the-Installation option is successful, you must specify a Log Path setting or-Log Path runtime option.
To run MongoDB services:
Net start MongoDB
Others
If you want to use another path for your DBPATH to install in the specified configuration file (for example, C: \ mongodb \ mongod. cfg. You can also specify-DBPATH on the command line, but always like the configuration file.
If the dbpath'directory does not exist, mongod.exe cannot start. The default DBPATH is \ DATA \ DB.
Stop or delete the MongoDB service renewal ¶
To stop MongoDB services:
Net stop MongoDB
Services to delete MongoDB:
C: \ mongodb \ bin \ mongod.exe -- remove
Tip:
When installing Windows Service, you need to right-click and run the command on the Administrator. In the configuration file, you need to set the log and db configuration items, for example:
Logpath = D: \ mongodb \ log \ mongo. log
Dbpath = D: \ mongodb \ db