[1] 创建directorys和files

Create a configuration file and a directory path for MongoDB log output (logpath):
 
首先要手动新建Windows服务:
 
 
创建日志文件的地址:
md  "C:\Program Files\MongoDB\log"
 
在命令提示行,为logpath创建一个配置文件:
echo logpath=C:\Program Files\MongoDB\log\mongo.log> "C:\Program Files\MongoDB\mongod.cfg" --install
[2] 运行MongoDB service
 
 
官方资料:
 
1. 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"

2. 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

3. 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.

1

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.

2

Create directories.

Create directories for your database and log files:

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

Create a configuration file.

Create a configuration file. This file can include any of the configuration options for mongod, butmust 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"
4

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
 
 
 
 
 
 
 
 
 
 
 

配置MongoDB的Windows服务的更多相关文章

  1. MongoDB安装Windows服务

    由于官方下载较慢.这里提供一个个人百度共享网盘地址: http://pan.baidu.com/s/1mhHW0nI mongodb-win32-x86_64-3.2.3 使用以下命令将MongoDB ...

  2. 安装MongoDB(做成Windows服务)并加载C#驱动程序

    一 Mongodb简介: 通过查询网上的一些信息来介绍一下Mongodb的优势:MongoDB是一个面向文档的数据库,目前由10gen开发并维护,它的功能丰富,齐全,完全可以替代MySQL.在使用Mo ...

  3. MongoDB作为windows服务来安装

    首先区官网下载对应版本的安装文件,我本地的环境是win7 bit64 我下载的版本是:mongodb-win32-x86_64-2.4.6 ok, 文件下载后,开始安装,这里要说一下,如果直接启动Mo ...

  4. MongoDB作为windows服务来安装-2

    首先区官网下载对应版本的安装文件,我本地的环境是win7 bit64 我下载的版本是:mongodb-win32-x86_64-2.4.6 ok, 文件下载后,开始安装,这里要说一下,如果直接启动Mo ...

  5. 配置jboss为windows服务

    先确保jdk和jboss的环境变量是正常可用的 1.(下载binaries 2.x.x-windows x86)找到service.bat和jbosssvc.exe两个文件 1.1 binaries ...

  6. MongoDB注册Windows服务启动

    下载MongoDB安装到:E:\Work_App\MongoDB 这个目录 安装:E:\Work_App\MongoDB (安装在专门的目录中) 配置: 1.在E:\Work_App\MongoDB\ ...

  7. mongoDB创建windows服务启动解决

    最近想了解一下关于MongoDB的知识,记得之前电脑上安装的MongoDB也能正常启用,可是这次在使用mongodb,却遇到一下小麻烦啊.mongodb无法启动,小编很苦恼,尝试了各种方法,甚至卸载重 ...

  8. 2、Redis如何配置成一个windows服务并且设置一键安装卸载与启停

    每天启动redis虽然只是一个命令行的事情,但是还是比较烦,所以…… 参考文档:Windows Service Documentation.docx 默认前提:Redis已安装并配置完成(不知道如何配 ...

  9. MongoDB作为Windows服务来安装 错误1053:服务没有及时响应启动或控制请求

    这个问题我解决了一晚上,用尽了所有百度 博客上的方法,都是失败的 结果重新换了一种安装的方法 视频讲解  非常清楚 https://www.bilibili.com/video/av31240330? ...

随机推荐

  1. Vmware ESXI 安装Windows

    Vmware ESXI 安装Windows >ESXi专为运行虚拟机.最大限度降低配置要求和简化部署而设计.只需几分钟时间,客户便可完成从安装到运行虚拟机的全过程,特别是在下载并安装预配置虚拟设 ...

  2. CSS基本样式-背景属性

    代码是敲出来的,建议一个一个过一遍 背景属性 背景颜色 background-color 背景颜色 默认值是transparent(透明的) 示例代码 <!DOCTYPE html> &l ...

  3. 使用render函数渲染组件

    使用render函数渲染组件:https://www.jianshu.com/p/27ec4467a66b

  4. queue的常见用法

    queue的使用 queue是什么? queue是一种先入先出的容器 queue的定义 引入 # include <iostream> # include <queue> us ...

  5. py3.7安装Scrapy及安装时的 Running setup.py install for Twisted ... error 和安装后的 Unhandled error in Deferred:

    1.首先,win+r 进入cmd,打开命令提示符,输入  pip install scrapy  等待自动安装: 2.到了后半段会出现  Running setup.py install for Tw ...

  6. 08.AutoMapper 之嵌套映射(Nested Mappings)

    https://www.jianshu.com/p/013715d2352d   嵌套映射(Nested Mappings) 当映射引擎执行映射时,它可以使用各种方法之一来解析目标成员值.其中一种方法 ...

  7. luogu P4076 [SDOI2016]墙上的句子

    luogu loj 题意看了我半天(逃 (应该是我语文太差了) 题意是要确定每一行和每一列的看单词的顺序,使得同时正着出现和反着出现在里面的单词数量最少,每行和每列的性质是这一行所有单词反过来的单词要 ...

  8. Thymeleaf后台传值读取

    /** * 测试用Controller *  * @author  * @date 2019-08-15 */@Controller@RequestMapping("/danyu/test& ...

  9. Assets.xcassets的详细使用方法

    开始之前,首先回顾一下iOS7初体验(1)——第一个应用程序HelloWorld中的一张图,如下所示: 本文分享一下Images.xcassets的体验~_~ 1. 打开此前使用过的HelloWorl ...

  10. C语言:标准IO_fopen( )、fclose() ①

    思前想后一个月,我终于敲下了我的第一篇开山之作. 博客千千万,我的博客首先记录的是学习时候的理解,用于给自己翻阅查找,现在主要研究的是C语言和STM32.如果能帮到你,那是最好的,假如我写的东西有错误 ...