Not authorized for query on admin.system.namespaces on mongodb

前端 未结 6 899
暗喜
暗喜 2021-02-02 00:07

I start a new mongo instance, create a user, authorize it, but when I run \"show collections\", the system says that the id is not authorized. I do not know why?



        
6条回答
  •  滥情空心
    2021-02-02 01:06

    I solved it like so for mongoDB 2.6 + currently 3

    db.createUser(
      {
        user: "username",
        pwd: "password",
        roles: [ { role: "root", db: "admin" } ]
      }
    )
    

    note that for the role filed instead of userAdminAnyDatabase we use root

提交回复
热议问题