The following are the learning notes:
1. Go to mongodb Download Center to download the appropriate installation file for your computer's operating system: Https://www.mongodb.com/download-center#enterprise
2. Locate the. msi file, double-click Run Follow the steps to install it.
Set up the MongoDB environment.
MongoDB requires a data directory to store all data. MongoDB's default data directory path is the absolute path to the drive from \data\db
which you start MongoDB. Create This folder by running the following command in a command Prompt:
\data\db
You can specify a alternate path for data files using --dbpath
mongod.exe
the option to, for example:
"C:\Program Files\mongodb\server\3.6\bin\mongod.exe"--dbpath d:\test\mongodb\data
If your path includes spaces, enclose the entire path in a double quotes, for example:
-"D:\test\mongo db data"
Also specify the in dbpath
a configuration file.
Start MongoDB.
To start MongoDB, run mongod.exe
. For example, from the Command Prompt:
"C:\Program Files\mongodb\server\3.6\bin\mongod.exe"
This starts the main MongoDB database process. The waiting for connections
message in the console output indicates, the mongod.exe
process is running successfully.
Depending on the security level of your system, Windows could pop up a Security Alert dialog box about blocking "some FE Atures "of from C:\Program Files\MongoDB\Server\3.6\bin\mongod.exe
communicating on networks. All users should select and Private Networks, such as my home or work network
click Allow access
. For additional information in security and MongoDB, please see the Security documentation.
3Connect to MongoDB.
To connect to MongoDB through mongo.exe
the shell, open another Command Prompt.
"C:\Program Files\mongodb\server\3.6\bin\mongo.exe"
If you want to develop applications using. NET, see the documentation of C # and MongoDB for more information.
4Begin using MongoDB.
To the 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 in the Control+C
terminal where the mongod
instance is running.
Configure a Windows Service for MongoDB enterprise1open an Administrator command prompt.
Press the Win
key, type cmd.exe
, and press to Ctrl + Shift + Enter
run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
2Create directories.
Create directories for your database and log files:
mkdir C:\data\dbmkdir C:\data\log
3Create 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 that C:\Program Files\MongoDB\Server\3.6\mongod.cfg
specifies both systemLog.path
and storage.dbPath
:
Systemlog: destinationfile pathc:\data\log\mongod.logstorageDbPathC : \data\db
4Install the MongoDB service.
Important
Run all of the following commands in Command Prompt with "administrative privileges".
Install the MongoDB service by starting with the option and the mongod.exe
--install
option to specify the -config
previously created Configuration file.
---install
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 the services for multiple instances of mongod.exe
or mongos.exe
. Install each service with a unique --serviceName
and --serviceDisplayName
. Use multiple instances if sufficient system resources exist and your system design requires it.
5Start the MongoDB service.
Mongodb
6Stop or remove the MongoDB service as needed.
To stop the MongoDB service with the following command:
Mongodb
To remove the MongoDB service use the following command:
--remove
Manually Create a Windows Service for MongoDB Enterprise
You can set up the MongoDB server as a Windows Service This starts automatically at boot time.
The following procedure assumes you has installed MongoDB using the .msi
installer with the path C:\Program Files\MongoDB\Server\3.4\
.
If you have installed in a alternative directory, you'll need to adjust the paths as appropriate.
1Open an Administrator command prompt.
Press the Win
key, type cmd.exe
, and press to Ctrl + Shift + Enter
run the Command Prompt as Administrator.
Execute the remaining steps from the Administrator command prompt.
2Create directories.
Create directories for your database and log files:
mkdir C:\data\dbmkdir C:\data\log
3Create 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 that C:\Program Files\MongoDB\Server\3.6\mongod.cfg
specifies both systemLog.path
and storage.dbPath
:
Systemlog: destinationfile pathc:\data\log\mongod.logstorageDbPathC : \data\db
4Create the MongoDB service.
Create the MongoDB service.
Sc.exe create MongoDB binpath= "\" C:\Program files\mongodb\server\3.6\bin\mongod.exe\ "--service--config=\" c \ Program files\mongodb\server\3.6\mongod.cfg\ "" Displayname= "MongoDB" start= "Auto"
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 would display:
SUCCESS
5Start the MongoDB service.
Mongodb
6Stop or remove the MongoDB service as needed.
To stop the MongoDB service, use the following command:
Mongodb
To remove the MongoDB service, first stop the service and then run the following command:
SC. MongoDB
MongoDB with notes 2--install DB