I installed mongodb on windows 8.1
我在windows 8.1上安装了mongodb
then I use command promp to navigate to D:\mongodb\bin
然后使用命令promp导航到D:\mongodb\bin
then I use this command
然后我使用这个命令
mongod.exe --config D:\mongodb\mongodb.conf
The content of mongodb.conf
mongodb.conf的内容
bind_ip = 127.0.0.1,100.100.100.100
port = 3979
quiet = true
dbpath = D:\mongodb\data\db
logpath = D:\mongodb\data\log\mongodb.log
logappend = true
journal = true
But mongod doesn't start. If I use mongod.exe (without using config file), it works perfectly
但mongod不开始。如果我使用mongod。exe(不使用配置文件),它的工作非常完美。
UPDATE:
更新:
My intention is simple: change default port to another port and only allow access from certain IP addresses.
我的意图很简单:将默认端口更改为另一个端口,只允许从某些IP地址访问。
I was using the configuration for Ubuntu. Thanks to Panda_Claus that pointed out the new configuration.
我在使用Ubuntu的配置。感谢Panda_Claus提出了新的配置。
So I changed the configuration to
所以我改变了构型
net:
bindIp: 127.0.0.1,100.100.100.100
port: 3979
The problem is, when I start mongod with this configuration, it got error then automatically exits
问题是,当我用这个配置启动mongod时,它会有错误然后自动退出
ERROR: listen(): bind() failed errno:10049 The requested address is not valid in its context. for socket: 100.100.100.100:3979
So how do I allow only localhost and a specific IP address (in this case is 100.100.100.100) to connect to mongodb?
那么,如何只允许localhost和特定的IP地址(在本例中是100.100.100.100.100)连接到mongodb呢?
UPDATE 2
更新2
I used the configuration from maerics
我使用了来自maerics的配置
net:
bindIp: 127.0.0.1,192.168.10.104
port: 3979
storage:
dbPath: D:\mongodb\data\db
journal:
enabled: true
systemLog:
destination: file
path: D:\mongodb\data\log\mongodb.log
quiet: true
logAppend: true
Interestingly, using this, I can only connect to db on local machine, other LAN computer can't connect to
有趣的是,使用这个,我只能连接到本地机器上的db,其他的LAN计算机不能连接
192.168.10.104:3979.
However, if I remove the
但是,如果我删除
systemLog:
destination: file
path: D:\mongodb\data\log\mongodb.log
quiet: true
logAppend: true
other computers in LAN network are able connect to the database.
LAN网络中的其他计算机可以连接到数据库。
2 个解决方案
#1
10
The config file must be valid YAML.
Try modifying the sample file provided with the documentation, for example:
尝试修改文档提供的示例文件,例如:
net:
bindIp: 127.0.0.1
port: 3979
storage:
dbPath: D:\mongodb\data\db
journal:
enabled: true
systemLog:
destination: file
path: D:\mongodb\data\log\mongodb.log
quiet: true
logAppend: true
#2
3
Not a mongo expert, but it appears from the mongo documentation that you should be using ":" as separators instead of "=".
不是mongo专家,但是从mongo文档中可以看出,您应该使用“:”作为分隔符,而不是“=”。
Here's a link I found to support this:
下面是我发现的一个支持这一观点的链接:
[1]: [http://docs.mongodb.org/manual/reference/configuration-options/ "Mongo config file format"][1]
[1]: [http://docs.mongodb.org/manual/reference/configur-options/ "Mongo配置文件格式"][1]
#1
10
The config file must be valid YAML.
Try modifying the sample file provided with the documentation, for example:
尝试修改文档提供的示例文件,例如:
net:
bindIp: 127.0.0.1
port: 3979
storage:
dbPath: D:\mongodb\data\db
journal:
enabled: true
systemLog:
destination: file
path: D:\mongodb\data\log\mongodb.log
quiet: true
logAppend: true
#2
3
Not a mongo expert, but it appears from the mongo documentation that you should be using ":" as separators instead of "=".
不是mongo专家,但是从mongo文档中可以看出,您应该使用“:”作为分隔符,而不是“=”。
Here's a link I found to support this:
下面是我发现的一个支持这一观点的链接:
[1]: [http://docs.mongodb.org/manual/reference/configuration-options/ "Mongo config file format"][1]
[1]: [http://docs.mongodb.org/manual/reference/configur-options/ "Mongo配置文件格式"][1]