Reputation: 24717
I have the following config as mongod.cfg:
systemLog:
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
net:
http:
enabled: true
I'm running MongoDB 2.6.3 on Windows 7 64 bit by running: mongod --config mongod.cfg
I'm inside the folder and I know it's parsing the correct mongod.cfg. However, I'm getting the following output:
Unrecognized option: net.http
try 'mongod --help' for more information
I am pulling my hair out wondering why it's not parsing. I'm reading straight from the configuration page on Mongo's site and I still can't make it work. Any ideas?
Upvotes: 2
Views: 3593
Reputation: 9850
I also met the similar issue when add auth to MongoDB admin user. When install MongoDB 3.0.8 or 3.0.15, the error appears:
CONTROL Hotfix kb2731284 or a later update is not installed, will zero-out files.
Fail to install kb2731284(obtained from MS's mail) in my PC whose OS is win7 enterprise version, no vaild resolution online.
Unrecognized option: net.http
try 'mongod --help' for more information
Then update MongoDB to v3.6 can avoid the error in the beginning, but now if want to add auth for MongoDB user using the mongod.cfg file, following content need to be used:
systemLog:
destination: file
path: "D:\\mongodb\\log\\mongodb.log"
logAppend: true
storage:
dbPath: "D:\\mongodb"
journal:
enabled: true
engine: wiredTiger
net:
port: 27017
setParameter:
enableLocalhostAuthBypass: false
mongod.cfg
.
Create folder C:\mongodb\data\
,
then create subfolder C:\mongodbdata\log
,
Copy the mongod.cfg file to related location of MongoDB bin, such as C:\ProgramFiles\MongoDB\Server\3.6\bin\
.
Then set value enableLocalhostAuthBypass
in mongod.cfg
file to true.
Open cmd.exe with the administrator privilege:
"C:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.exe" "--config=c:\ProgramFiles\MongoDB\Server\3.6\bin\mongod.cfg" --auth --install
If the mongodb service is not running, type net start mongodb
C:\Users\{username}\Desktop>netstart mongodb
> use admin
> db.createUser("admin", "yourpassword", roles: ["root"]})
> db.auth(user, yourpassword)
Restart MongoDB from commond line.
Set value enableLocalhostAuthBypass
to false
.
Since for MongoDB 3.6 (actually any version after v3.2) have removed the net.http
options (Refer: https://docs.mongodb.com/manual/reference/configuration-options/).
Then all issues met can be completely solved.
Upvotes: 0
Reputation: 24717
Turns out I needed spaces after the headers. It needed to be:
systemLog:<space>
destination: file
path: "C:\Program Files\MongoDB 2.6 Standard\logs\mongo.log"
logAppend: true
storage:<space>
dbPath: "C:\Program Files\MongoDB 2.6 Standard\data\"
net:<space>
http:<space>
enabled: true
Upvotes: 3