md \data\dbYou can specify an alternate path for data files using the --dbpath option to mongod.exe, for example:
C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\dataIf your path includes spaces, enclose the entire path in double quotes, for example:
C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"You may also specify the dbpath in a configuration file.2
Start MongoDB.
To start MongoDB, run mongod.exe. For example, from the Command Prompt:C:\mongodb\bin\mongod.exeThis starts the main MongoDB database process. The waiting for connections message in the console output indicates that the mongod.exe process is running successfully.Depending on the security level of your system, Windows may pop up a Security Alert dialog box about blocking “some features” of C:\mongodb\bin\mongod.exe from communicating on networks. All users should select Private Networks, such as my home or worknetwork and click Allow access. For additional information on security and MongoDB, please see the Security Documentation.3
Connect to MongoDB.
To connect to MongoDB through the mongo.exe shell, open another Command Prompt.C:\mongodb\bin\mongo.exeIf you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.4
Begin using MongoDB.
To help you 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 Control+C in the terminal where the mongod instance is running.Configure a Windows Service for MongoDB Community Edition
1Open an Administrator command prompt.
Press the Win key, type cmd.exe, and press Ctrl + Shift + Enter to 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\db mkdir c:\data\log3
Create 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 C:\mongodb\mongod.cfg that specifies both systemLog.path andstorage.dbPath:systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db4Install the MongoDB service.
IMPORTANTRun all of the following commands in Command Prompt with “Administrative Privileges”.Install the MongoDB service by starting mongod.exe with the --install option and the -configoption to specify the previously created configuration file."C:\mongodb\bin\mongod.exe" --config "C:\mongodb\mongod.cfg" --installTo 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 services for multiple instances of mongod.exe or mongos.exe. Install each service with a unique --serviceName and --serviceDisplayName. Use multiple instances only when sufficient system resources exist and your system design requires it.5
Start the MongoDB service.
net start MongoDB6
Stop or remove the MongoDB service as needed.
To stop the MongoDB service use the following command:net stop MongoDBTo remove the MongoDB service use the following command:
"C:\mongodb\bin\mongod.exe" --remove
Manually Create a Windows Service for MongoDB Community Edition
You can set up the MongoDB server as a Windows Service that starts automatically at boot time.The following procedure assumes you have installed MongoDB Community using the .msi installer with the path C:\mongodb\.If you have installed in an alternative directory, you will need to adjust the paths as appropriate.1Open an Administrator command prompt.
Press the Win key, type cmd.exe, and press Ctrl + Shift + Enter to 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\db mkdir c:\data\log3
Create 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 C:\mongodb\mongod.cfg that specifies both systemLog.path andstorage.dbPath:systemLog:
destination: file
path: c:\data\log\mongod.log
storage:
dbPath: c:\data\db4Create the MongoDB service.
Create the MongoDB service.sc.exe create MongoDB binPath= "C:\mongodb\bin\mongod.exe --service --config=\"C:\mongodb\mongod.cfg\"" DisplayName= "MongoDB" start= "auto"
更多:联想电脑i3台式电脑Install MongoDB Community Edition on Windows
https://www.002pc.com/diannaojichu/828.html
你可能感兴趣的Windows,MongoDB,Community,Install,Edition
