Windows下安装mongodb

 

1. Download MongoDB

2. Install MongoDB

3. Create the required folders:

"C:MongoDB_2_6_Standardindatadb"

"C:MongoDB_2_6_Standardlogs"

"C:MongoDB_2_6_Standardetc"

NOTE: If the directories do not exist, mongod.exe will not start.

4. Create a simple configuration file:

systemLog:

destination: file

path: "C:\MongoDB_2_6_Standard\logs\mongo.log"

logAppend: true

net:

bindIp: 127.0.0.1

port: 27017

(如果用记事本编辑总是报错,可是用notepad++打开后保存再保存。)

 [注] mongo 3.2和mongo3.6有些不同, 3.2默认是开启远程连接的,3.6默认是不开启的,要用bindIp或者bindIpAll:true来进行设置. 

More info about how to create a configuration file:http://docs.mongodb.org/manual/reference/configuration-options/

5. Install MongoDB as a Windows Service (this way it will start automatically when you reboot your computer)

Run cmd with administrator privilegies, and enter the following commands:

"C:MongoDB_2_6_Standardinmongod.exe" --config "C:MongoDB_2_6_Standardetcmongodb.conf" --dbpath "c:MongoDB_2_6_Standardindatadb" --directoryperdb --install

6. Start the MongoDB Windows Service

net start MongoDB

7. Connect to MongoDB via shell/cmd for testing

C:MongoDB_2_6_Standardinmongo.exe

NOTE: http://docs.mongodb.org/manual/tutorial/getting-started-with-the-mongo-shell/

8. That's it! You are done. :)

9. Uninstall/remove the MongoDB Windows Service (if you messed up something)

"C:MongoDB_2_6_Standardinmongod.exe" --remove

原文地址:https://www.cnblogs.com/time-is-life/p/4549309.html