Overview

Use this tutorial to install MongoDB on a Windows systems.

PLATFORM SUPPORT

Starting in version 2.2, MongoDB does not support Windows XP. Please use a more recent version of Windows to use more recent releases of MongoDB.

IMPORTANT

If you are running any edition of Windows Server 2008 R2 or Windows 7, please install a hotfix to resolve an issue with memory mapped files on Windows.

Install MongoDB

Determine which MongoDB build you need.

There are three builds of MongoDB for Windows:

MongoDB for Windows Server 2008 R2 edition (i.e. 2008R2) runs only on Windows Server 2008 R2, Windows 7 64-bit, and newer versions of Windows. This build takes advantage of recent enhancements to the Windows Platform and cannot operate on older versions of Windows.

MongoDB for Windows 64-bit runs on any 64-bit version of Windows newer than Windows XP, including Windows Server 2008 R2 and Windows 7 64-bit.

MongoDB for Windows 32-bit runs on any 32-bit version of Windows newer than Windows XP. 32-bit versions of MongoDB are only intended for older systems and for use in testing and development systems. 32-bit versions of MongoDB only support databases smaller than 2GB.

To find which version of Windows you are running, enter the following command in the Command Prompt:

wmic os get osarchitecture
 

Download MongoDB for Windows.

Download the latest production release of MongoDB from the MongoDB downloads page. Ensure you download the correct version of MongoDB for your Windows system. The 64-bit versions of MongoDB does not work with 32-bit Windows.

Install the downloaded file.

In Windows Explorer, locate the downloaded MongoDB msi file, which typically is located in the default Downloads folder. Double-click the msi file. A set of screens will appear to guide you through the installation process.

Move the MongoDB folder to another location (optional).

To move the MongoDB folder, you must issue the move command as an Administrator. For example, to move the folder to C:\mongodb:

Select Start Menu > All Programs > Accessories.

Right-click Command Prompt and select Run as Administrator from the popup menu.

Issue the following commands:

cd \
move C:\mongodb-win32-* C:\mongodb
MongoDB is self-contained and does not have any other system dependencies. You can run MongoDB from any folder you choose. You may install MongoDB in any folder (e.g.D:\test\mongodb)

Run MongoDB

WARNING

Do not make mongod.exe visible on public networks without running in “Secure Mode” with the auth setting. MongoDB is designed to be run in trusted environments, and the database does not enable “Secure Mode” by default.

 

Set up the MongoDB environment.

MongoDB requires a data directory to store all data. MongoDB’s default data directory path is\data\db. Create this folder using the following commands from a Command Prompt:

md \data\db

You 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\data

If your path includes spaces, enclose the entire path in double quotes, for example:

C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"
 

Start MongoDB.

To start MongoDB, run mongod.exe. For example, from the Command Prompt:

C:\Program Files\MongoDB\bin\mongod.exe

This 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:\Program Files\MongoDB\bin\mongod.exe from communicating on networks. All users should select Private Networks, such as my home orwork network and click Allow access. For additional information on security and MongoDB, please see the Security Documentation.

 

Connect to MongoDB.

To connect to MongoDB through the mongo.exe shell, open another Command Prompt. When connecting, specify the data directory if necessary. This step provides several example connection commands.

If your MongoDB installation uses the default data directory, connect without specifying the data directory:

C:\mongodb\bin\mongo.exe

If you installation uses a different data directory, specify the directory when connecting, as in this example:

C:\mongodb\bin\mongod.exe --dbpath d:\test\mongodb\data

If your path includes spaces, enclose the entire path in double quotes. For example:

C:\mongodb\bin\mongod.exe --dbpath "d:\test\mongo db data"

If you want to develop applications using .NET, see the documentation of C# and MongoDB for more information.

 

Begin using MongoDB.

To begin using MongoDB, see Getting Started with MongoDB. Also consider the Production Notes document before deploying MongoDB in a production environment.

Configure a Windows Service for MongoDB

NOTE

There is a known issue for MongoDB 2.6.0, SERVER-13515, which prevents the use of the instructions in this section. For MongoDB 2.6.0, use Manually Create a Windows Service for MongoDB to create a Windows Service for MongoDB instead.

 

Configure directories and files.

Create a configuration file and a directory path for MongoDB log output (logpath):

Create a specific directory for MongoDB log files:

md "C:\Program Files\MongoDB\log"

In the Command Prompt, create a configuration file for the logpath option for MongoDB:

echo logpath=C:\Program Files\MongoDB\log\mongo.log > "C:\Program Files\MongoDB\mongod.cfg"
 

Run the MongoDB service.

Run all of the following commands in Command Prompt with “Administrative Privileges:”

Install the MongoDB service. For --install to succeed, you must specify the logpath run-time option.

"C:\Program Files\MongoDB\bin\mongod.exe" --config "C:\Program Files\MongoDB\mongod.cfg" --install

Modify the path to the mongod.cfg file as needed.

To use an alternate dbpath, specify the path in the configuration file (e.g. C:\ProgramFiles\MongoDB\mongod.cfg) or on the command line with the --dbpath option.

If the dbpath directory does not exist, mongod.exe will not start. The default value for dbpath is\data\db.

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.

 

Stop or remove the MongoDB service as needed.

To stop the MongoDB service use the following command:

net stop MongoDB

To remove the MongoDB service use the following command:

"C:\Program Files\MongoDB\bin\mongod.exe" --remove
Manually Create a Windows Service for MongoDB

The following procedure assumes you have installed MongoDB using the MSI installer, with the default path C:\Program Files\MongoDB 2.6 Standard.

If you have installed in an alternative directory, you will need to adjust the paths as appropriate.

 

Open an Administrator command prompt.

Windows 7 / Vista / Server 2008 (and R2)

Press Win + R, then type cmd, then press Ctrl + Shift + Enter.

Windows 8

Press Win + X, then press A.

Execute the remaining steps from the Administrator command prompt.

 

Create directories.

Create directories for your database and log files:

mkdir c:\data\db
mkdir c:\data\log
 

Create a configuration file.

Create a configuration file. This file can include any of the configuration options for mongod, but must include a valid setting for logpath:

The following creates a configuration file, specifying both the logpath and the dbpath settings in the configuration file:

echo logpath=c:\data\log\mongod.log> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"
echo dbpath=c:\data\db>> "C:\Program Files\MongoDB 2.6 Standard\mongod.cfg"

Create the MongoDB service.

Create the MongoDB service.

sc.exe create MongoDB binPath= "\"C:\Program Files\MongoDB 2.6 Standard\bin\mongod.exe\" --service --config=\"C:\Program Files\MongoDB 2.6 Standard\mongod.cfg\"" DisplayName= "MongoDB 2.6 Standard" 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 will display:

[SC] CreateService SUCCESS
5

Start the MongoDB service.

net start MongoDB
6

Stop or remove the MongoDB service as needed.

To stop the MongoDB service, use the following command:

net stop MongoDB

To remove the MongoDB service, first stop the service and then run the following command:

sc.exe delete MongoDB

Install MongoDB on Windows的更多相关文章

  1. Install MongoDB on Windows (Windows下安装MongoDB)

    Install MongoDB on Windows Overview Use this tutorial to install MongoDB on a Windows systems. PLATF ...

  2. Mongodb在Windows 7下的安装及配置

    第一步 下载MongoDB: 下载mongodb的windows版本,有32位和64位版本,根据操作系统情况下载,下载地址:http://www.mongodb.org/downloads 解压缩至指 ...

  3. mongoDB在windows下安装与配置方案

    首先在官网下载mongoDB的安装包: https://www.mongodb.org/downloads 百度云盘下载:http://pan.baidu.com/s/1slUSGYp (安装版 wi ...

  4. Mongodb For Windows

    关于 mongodb管理与安全认证 请移步这里: Mongodb For Mac OSX && 登录验证 安装mongodb 1. 官网下载 mongodb,如果嫌慢还可以前往百度云盘 ...

  5. mongoDB在windows下基于配置文件的安装和权限配置方式

    下载mongoDB  http://www.mongodb.org/downloads 根据操作系统,选择需要下载的安装包 添加mongodb 安装目录 将解压的文件夹中内容拷贝,存放在想要安装的文件 ...

  6. MongoDB在windows服务器安装部署及远程连接MongoDB

    (.\是表示在服务器的windows powershell下需要 表示信任此命令才会执行不然会报错,自己电脑上使用时可去掉.\) 在本地使用都不需要开启权限而在服务器上需要开启安全模式所以需要在原本的 ...

  7. Mongodb在Windows下安装及配置 【转】

    1.下载mongodb的windows版本,有32位和64位版本,根据系统情况下载,下载地址:http://www.mongodb.org/downloads 2.解压缩至E:/mongodb即可 3 ...

  8. PHP学习之-Mongodb在Windows下安装及配置

    Mongodb在Windows下安装及配置 1.下载 下载地址:http://www.mongodb.org/ 建议下载zip版本. 2.安装 下载windows版本安装就和普通的软件一样,直接下一步 ...

  9. mongoDB安装windows 64 bit

    mongoDB安装windows 64 bit   https://www.mongodb.org/downloads?_ga=1.207888916.746558625.1410501054 下载, ...

随机推荐

  1. overflow之锚点技术实现选项卡

    我们知道通过锚点技术可以实现页面内容的定位,如果我们把这些内容放置在一个容器中,看看我们能做什么.       艾玛,选项卡.轮播,有木有,瞬间有种蛋碎的赶脚,以前写个选项卡,破轮播,费了多大的劲儿呀 ...

  2. 快速使用Log4Cpp

    封了一下接口,快速使用. 其他的你都不用管了. 这里封装了需要读取外部conf文件配置输出项.否则可以用getInstance初始化日志类 #include "L4Cpp.h" v ...

  3. html锚点

    ID模式 <h3><a href="#start">开始</a></h3> <div> 你好 <b/> &l ...

  4. 使用dynamic来简化反射实现

    dynamic是Framework4.0的新特性,dynamic的出现让C#具有了弱语言类型的特性,编译器在编译的时候,不再对类型进行检查,不会报错,但是运行时如果执行的是不存在的属性或者方法,运行程 ...

  5. ~/.vimrc config

    runtime! debian.vim "设置编码 set encoding=utf- set fencs=utf-,ucs-bom,shift-jis,gb18030,gbk,gb2312 ...

  6. 从 IT 的角度思考 BIM(一):面向对象

    还记得那个笑话吗:要把大象放进冰箱,总共分几步?这不仅仅是一个笑话,还是一个值得我们好好分析的笑话. 如果要放进冰箱的是一个苹果,那么也就不可笑了,但换成大象,就引起了我们的兴趣和注意,为什么? 我们 ...

  7. qt 5 基础知识 2(控件篇)

    QVBoxLayout *lay = new QVBoxLayout(this); // 创建一个竖直的盒子 lebel 篇 lay->addWidget(label = new QLabel( ...

  8. 双数组Trie树 (Double-array Trie) 及其应用

    双数组Trie树(Double-array Trie, DAT)是由三个日本人提出的一种Trie树的高效实现 [1],兼顾了查询效率与空间存储.Ansj便是用DAT(虽然作者宣称是三数组Trie树,但 ...

  9. Linux技术修复

    今天在慕课网上学习了Linux的一些知识: 我使用命令: ***:~$ route add default gw 192.168.1.1 添加了一个网关:192.168.1.1之后的结果为: ***: ...

  10. Uva 10294 Arif in Dhaka (First Love Part 2)

    Description 现有一颗含\(N\)个珠子的项链,每个珠子有\(t\)种不同的染色.现求在旋转置换下有多少种本质不同的项链,在旋转和翻转置换下有多少种本质不同的项链.\(N < 51,t ...