[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. Python 爬取SeeBug poc

    #!/usr/bin/env python # -*- coding: utf-8 -*- # @Date : 2017-08-24 21:42:52 # @Author : EnderZhou (z ...

  2. java中易错点

    1.A instanceof  B{这是没有好好利用java多态的表现} java中的二元操作符,测试A对象是否是B类的实例: 返回值:boolean类型 2.“==”与 “equals”的区别: = ...

  3. SpringBoot自动化配置之二:自动配置(AutoConfigure)原理、EnableAutoConfiguration、condition

    自动配置绝对算得上是Spring Boot的最大亮点,完美的展示了CoC约定优于配置: Spring Boot能自动配置Spring各种子项目(Spring MVC, Spring Security, ...

  4. 快速安装create-react-app脚手架

    create-react-app搭建react项目:https://blog.csdn.net/weixin_41077029/article/details/82622106 快速安装create- ...

  5. HDU 1401 Solitaire 双向DFS

    HDU 1401 Solitaire 双向DFS 题意 给定一个\(8*8\)的棋盘,棋盘上有4个棋子.每一步操作可以把任意一个棋子移动到它周围四个方向上的空格子上,或者可以跳过它四个方向上的棋子(就 ...

  6. noip2013day2-华容道

    题目描述 小 \(B\) 最近迷上了华容道,可是他总是要花很长的时间才能完成一次.于是,他想到用 编程来完成华容道:给定一种局面,华容道是否根本就无法完成,如果能完成,最少需要多 少时间. 小 \(B ...

  7. PhpStorm配置Xdebug调试

    安装xdebug 去官网下载对应版本的xdebug扩展 XDEBUG EXTENSION FOR PHP | DOWNLOADS 如何选择正确版本 输出phpinfo()函数的内容 查看输出页面的网页 ...

  8. Python 入门之 内置模块 -- random模块

    Python 入门之 内置模块 -- random模块 1.random模块 import random # random -- 随机数 (1)选择1-50之间随机的整数 print(random.r ...

  9. 从头到尾说一次 Java 垃圾回收,写得非常好! (转)

    之前上学的时候有这个一个梗,说在食堂里吃饭,吃完把餐盘端走清理的,是 C++ 程序员,吃完直接就走的,是 Java 程序员.

  10. 2015 四川省赛 C Censor(哈希 | KMP)

    模式串为子串 KMP /* @author : victor */ #include <bits/stdc++.h> using namespace std; typedef long l ...