Reputation: 17486
Well, restarting works with stop and start command, but I cannot seem to execute the mongodb command with --auth option.
root@random:/home/random/public_html# mongodb stop
root@random:/home/random/public_html# start mongodb --auth
start: invalid option: --auth
root@random:/home/random/public_html# start mongodb
mongodb start/running, process 29473
root@random:/home/random/public_html#
How can I start mongodb with --auth option?
Upvotes: 23
Views: 30793
Reputation: 7590
Edit /etc/mongod.conf
and add a line like this:
auth=true
Then:
service mongod restart
See this page for more configuration options: http://www.mongodb.org/display/DOCS/File+Based+Configuration
For MongoDB latest versions 3.x above code wont work, below code in mongod.conf if you are using mongodb 3.x
security:
authorization: enabled
Upvotes: 71
Reputation: 1805
For mongodb version 3.2
this is the correct config
security:
authorization: "enabled"
in String format
Upvotes: 17
Reputation: 7544
If you are using MongoDB 3, setting auth = true
wont work. You will instead need the following in your /etc/mongod.conf
security:
authorization: enabled
Upvotes: 61
Reputation: 587
Just want to supplement the answer. For MongoDB 3, the /etc/mongod.conf has changed. Either of below enable MondgoDB authorization option (--auth):
security: keyFile: [The path to a key file]
-- or--
security: authorization: enabled
Upvotes: 5
Reputation:
you should put the --auth
option in the startup script
/etc/rc[0-6].d/mongod
Upvotes: 0