1、官方网站下载zip包
2、建立工作目录
主目录 d:\Lab\bin\MongoDB\
数据库文件目录 d:\Lab\bin\MongoDB\data
mongodb目录 d:\Lab\bin\MongoDB\mongodb-2.6.6
log目录 d:\Lab\bin\MongoDB\mongodb-2.6.6\log
log文件 d:\Lab\bin\MongoDB\mongodb-2.6.6\log\mongodb.log
3、配置系统环境变量
4、在命令行中启动mongodb服务
mongod.exe --dbpath=D:\Lab\bin\MongoDB\data\ --logpath=D:\Lab\bin\MongoDB\mongodb-2.6.6\log\mongodb.log
结果显示如下
5、在web浏览器中输入http://localhost:27017/,可以看到如下内容:
It looks like you are trying to access MongoDB over HTTP on the native driver port.
说明启动成功
6、另外打开一个cmd窗口,输入:mongo。见如下
表明成功连接mongodb
7、如果出现错误,先看服务启动没有,如果没有启动服务先启动服务,如果服务已经启动了,那有可能是上次不正常关闭mongo,导致存放数据的文件被占用了,被锁住了。只需将D:\MongoDB\data中的mongod.lock文件删除掉。重新启动服务即可。
参考文档:
http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/
http://database.51cto.com/art/201208/353458.htm
http://my.oschina.net/u/1388758/blog/355385