Cannot authenticate into mongo, “auth fails”

前端 未结 12 1251
无人及你
无人及你 2020-11-30 21:40

I\'ve created an admin user for mongo using these directions:

http://docs.mongodb.org/manual/tutorial/add-user-administrator/

From the mongo client it looks

12条回答
  •  -上瘾入骨i
    2020-11-30 22:35

    Authentication is managed at a database level. When you try to connect to the system using a database, mongo actually checks for the credentials you provide in the collection .system.users. So, basically when you are trying to connect to "test", it looks for the credentials in test.system.users and returns an error because it cannot find them (as they are stored in admin.system.users). Having the right to read and write from all db doesn't mean you can directly connect to them.

    You have to connect to the database holding the credentials first. Try:

    mongo admin -u admin -p SECRETPASSWORD
    

    For more info, check this http://docs.mongodb.org/manual/reference/privilege-documents/

提交回复
热议问题