4
votes

I'm running the latest MongoDB for Ubuntu 14.04

  • I have created a user named "admin" with "userAdminAnyDatabase" role
  • I can access databases locally and externally
  • I can login with "admin' with SHA-SCRAM-1

When I edit to config file to restrict access only with authentication things go wrong. What happens:

  1. I uncomment "#auth = true" in the config file.
  2. I cannot access with the correct credentials of the "admin" account.

Bear in mind that I do use "service mongod restart" after making changes.

Config file for reference:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: /var/lib/mongodb
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path: /var/log/mongodb/mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 0.0.0.0


#processManagement:

#security:
#auth = true
#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:
#snmp:

Snapshot of database for reference:

Database

What's going wrong?

2
Which version of the manager are you using? Can you access mongo from the cli?baao
Using version 3.1.0.5 and yes I can, until I enable authorisation.ManyQuestions
Are you sure that manager supports SHA-SCRAM-1?Danny Varod
@DannyVarod It's an option in a ListView when creating a new connection so it should :)ManyQuestions
what command you are using for that may i know ? I have done the same thing in ubuntu 15.x versionAlok Deshwal

2 Answers

8
votes

I think that auth = true is an invalid configuration and your mongod is not starting because of it. To enable authorization, try using the following instead:

security:
  authorization: enabled

Then, to connect to the database, make sure that your client is using the correct authentication database and authentication mechanism. This can be done using the commmand line by the following command:

mongo localhost -u admin -p myAdminPass --authenticationDatabase admin --authenticationMechanism SCRAM-SHA-1
2
votes
  1. Did you follow the instructions in Enable Client Access Control to create the user and enable authentication?

  2. What is the output of your log, when you try to access mongoDB with credentials?

  3. Did you tell mongoDB somewhere to use the config file? Try to start mongoDB locally on the PC mongoDB is running with mongod --config ../etc/mongod.conf and then try to connect from your Windows PC like you did before.