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

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?

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

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

For mongodb version 3.2
this is the correct config
security:
authorization: "enabled"
in String format

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
Details can be found here

you should put the --auth option in the startup script
/etc/rc[0-6].d/mongod

Related

Enable authorization in MongoDB

I created some mongodb users and when I tried to enable Authorization I added this directive
security:
authorization: "enabled"
to /etc/mongod.config file, and when I restarted mongod it won't start and it exited with error.
My mongodb is version 5.x as a replicaset of three nodes.
Any thoughts?

authentication in MongoDB and Ubuntu

We installed MongoDB on windows(development) version 3.4, and enabled authentication, after running the command mongod --auth, the authentication was successfully implemented.
Now on the production server that is Ubuntu 16, with MongoDb version 4.0, we made changes to the mongod.conf file as seen below and then restated the mongod service with command sudo service mongod start, but now we are not able to connect to our MongoDB Ubuntu server.
security:
authorization: "enabled"
Where did we go wrong in implementing authentication for MongoDB on Ubuntu server.
security:
authorization: "enabled"
2 possible issues here : reading the doc, i'm not sure you need to quote the enabled word.
Moreover, yaml format need to increment sub part of conf, so your conf file have to look like :
security:
authorization: enabled
But cannot really test, since i don't have any running local instance

How to change Authentication MongoDB 3.2

mongoDB version 2.6 was an option file mongod.conf
Allow "Auth" Or "NoAuth"
How to do it now mongoDB version 3.2?
According to the Mongo docs here -
https://docs.mongodb.com/manual/reference/configuration-options/#security.authorization - one can enable authorization (which is DISABLED by default) by doing the following:
Edit the mongo settings file /etc/mongod.conf
Add the line:
security.authorization : enabled
Restart the service
Regards,

How to disable anonymous access to MongoDB 3.0.x in linux

we are using centos 7 , mongodb 3.0.8
Im trying to disable anonymous access to mongodb.
Place auth = true in /etc/mongod.conf disabling anonymous access in version 2.x
but in version 3 when i place the same , the server it self not starting
When i hard search , i found in the mongo docs that in version 3.x
security.authorization should be placed in /etc/mongod.conf
Could any one please help me how to place security.authorization in config file.
add the following to the mongod.conf file:
security:
authorization: enabled

oplog enable on standalone mongod not for replicaset

I am running mongod as standalone server .now i want to enable oplog for it ,i want to know whether it is possible or not ?
I knew I can do this by creating single node ReplicaSet ,but I want to do this without replica set .
I got a reply from the MongoDb Team, and it's working fine.
To enable oplog on a standalone server, start mongo with master options.
On command line start mongod --master.
For conf file append the following line:
master=true
More details here.
For mongo 2.6 or greater the /etc/mongod.conf now uses a yaml format.
To enable the oplog add something similar to the below, note the replication: line may already exist, be sure to use spaces.
replication:
replSetName: rs0
oplogSizeMB: 100
Full documentation here:
https://docs.mongodb.com/manual/reference/configuration-options/#replication-options