在 Windows 中使用 mongodb.config 设置 mongodb 配置路径
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25991315/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Set mongodb configuration path using mongodb.config in Windows
提问by vamsiampolu
I am trying to set up mongodb 2.6.3
on Windows,I have installed it and would like to configure the dbpath
using a mongodb.config
file at C:\Program Files\MongoDB 2.6 Standard\bin
我正在尝试mongodb 2.6.3
在 Windows 上进行设置,我已经安装了它并希望dbpath
使用以下位置的mongodb.config
文件进行配置C:\Program Files\MongoDB 2.6 Standard\bin
I have tried adding it like this:
我试过像这样添加它:
dbpath=E:\Do\mongodb
I have also tried to add it like this(tested it in YAML Parser
online):
我也尝试像这样添加它(YAML Parser
在线测试):
- storage:
- dbPath:"E:\Do\mongodb"
It seems like neither of these works,how can I set up config
options for my mongodb
.It does not even seem to be recognizing the configuration file,I even tried it mongod --config but it did not work.
似乎这些都不起作用config
,我如何为我的 .mongodb
它设置选项。它甚至似乎无法识别配置文件,我什至尝试过 mongod --config 但它没有用。
采纳答案by Lelouchzqy
It works for me, using :
它对我有用,使用:
dbpath=T:\data\db
My mongodb version is also 2.6.3
我的mongodb版本也是2.6.3
By the way, my config file is named "mongod.cfg", but yours is "mongodb.config". Maybe this counts.
顺便说一下,我的配置文件名为“mongod.cfg”,而你的是“mongodb.config”。也许这很重要。
Anyway, try to follow the tutorial:http://docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/It works
无论如何,请尝试按照教程进行操作:http: //docs.mongodb.org/manual/tutorial/install-mongodb-on-windows/它有效
回答by dzilbers
when you write the config file with "" i.e double quotes you should use \\ instead of \ for windows... Otherwise you will find that there is "unknown escape character" in this line of the config file
当你用 "" 即双引号编写配置文件时,你应该使用 \\ 而不是 \ for windows ...否则你会发现在配置文件的这一行中有“未知转义字符”
- storage:
- dbPath:"E:\Do\mongodb"