Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I restart mongodb with --auth option in Ubuntu 10.04?

Tags:

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?

like image 341
user482594 Avatar asked Jun 04 '11 09:06

user482594


2 Answers

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 
like image 105
Scott Hernandez Avatar answered Oct 23 '22 07:10

Scott Hernandez


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 
like image 40
Chiedo Avatar answered Oct 23 '22 07:10

Chiedo