---
title: "初识MongoDB（二）--Windows版本安装"
author: "wode66"
date: "2011-06-08T16:58:14Z"
tags: []
categories: ["数据库"]
slug: "mongodb-windows"
draft: false
lastmod: "2011-06-08T16:58:14Z"
id: 1073288
url: "https://suo.iteye.com/blog/1073288"
---

安装步骤：

(1)、下载MongoDB 　　 url地址: http://downloads.mongodb.org/win32/mongodb-win32-i386-1.8.1.zip 　　 (2)、设置MongoDB目录（解压zip文件） 　　 将其解压到 d:\\，再重命名为mongodb，路径为d:\\mongodb 　　 (3)、设置数据文件路径（默认路径为:/data/db目录） 　　 在d:盘建一个db文件夹，路径d:\\mongodb\\db

　　 (4)、启动MongoDB服务 　　 进入 cmd 提示符控制台，D:\\mongodb\\bin\\mongod.exe --dbpath=d:\\mongodb\\db

(5)、将MongoDB作为 Windows 服务随机启动

```
	D:\mongodb\bin>D:\mongodb\bin\mongod --dbpath=d:\data\db --logpath=d:\mongodb\logs\mongodb.log --install
	all output going to: d:\mongodb\logs\mongodb.log
	Creating service MongoDB.
	Service creation successful.
	Service can be started from the command line via 'net start "MongoDB"'.
	D:\mongodb\bin>net start mongodb
	Mongo DB 服务已经启动成功。
```

  (6)、客户端连接验证（shell方式）

CMD输入：d:\\mongodb\\bin\\mongo

 

**注意：**

**(1)、MongoDB服务端的默认连接端口是 27017**

**(2)、启动MongoDB后，可以使用以下url测试是否启动成功：**[http://localhost:28017/](http://localhost:28017/)

**(3)、让MongoDB以windows服务方式启动，执行以下命令：**

**mongod --dbpath "D:/****mongodb/db/" --logpath "D:/mongodb/logs.txt" --install --serviceName "MongoDB"**

 

 

转载自：[http://tech.it168.com/a2011/0417/1179/000001179081\_all.shtml](http://tech.it168.com/a2011/0417/1179/000001179081_all.shtml)