[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
 
 
 
 
 
 
 
 
 
 
 

最新文章

  1. [LeetCode] Nested List Weight Sum II 嵌套链表权重和之二
  2. Android ViewPager滑动背景渐变
  3. kickstart+ftp+tftp+dhcp+PXE
  4. Less入门到上手——前端开发利器<一>
  5. jQuery学习总结(一)
  6. springmvc源码分析(转)
  7. FZU2082树链剖分
  8. 二叉树建立,先序、中序、后序遍历(c实现)
  9. iFreeThinking - 记录生活,分享思考
  10. 【Mysql】初学命令行指南
  11. 常用的css的技巧
  12. nginx查看日志
  13. 做一个有理想的IT人
  14. MySQL基础之 path环境变量的作用 (科普)
  15. 使用after伪类清除浮动
  16. python初探-copy
  17. YouTube为什么打不开?以及简便的訪问的方法/解决方式!
  18. Android 通过调用系统,如接口 谷歌语音、百度语音、科大讯飞语音等语音识别方法对话框
  19. 追女神助手v0.1
  20. ASP.NET 应用程序遭遇Server Application Unavailable问题的解决的方法

热门文章

  1. nodejs+koa2 实现一个get请求
  2. Spring的核心思想,总结得非常好!
  3. Java四类八项基本数据类型
  4. map的常见用法
  5. awk对文件的奇偶行做处理
  6. 设计模式之单例模式(Singleton Pattern)
  7. centos7 设置内核启动顺序
  8. 089、初探ELK (2019-05-13 周一)
  9. 在mybatis中,在列表分页查询过程中造成集合属性数据丢失的问题
  10. 转载MySQL面试题