Can't connect to MongoDB with authentication enabled

前端 未结 2 383
花落未央
花落未央 2021-01-06 06:57

I\'m running the latest MongoDB for Ubuntu 14.04

  • I have created a user named \"admin\" with \"userAdminAnyDatabase\" role
  • I can access databases local
相关标签:
2条回答
  • 2021-01-06 07:16

    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
    
    0 讨论(0)
  • 2021-01-06 07:23
    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.

    0 讨论(0)
提交回复
热议问题