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

前端 未结 6 836
暗喜
暗喜 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 00:57

    I had the same problem, but I found this tutorial and it helped me.

    http://www.hacksparrow.com/mongodb-add-users-and-authenticate.html

    use:

    db.addUser('sa', 'sa')
    

    instead of

    db.addUser({user:"sa",pwd:"sa",roles:["userAdminAnyDatabase"]})
    {
            "user" : "sa",
            "pwd" : "75692b1d11c072c6c79332e248c4f699",
            "roles" : [
                    "userAdminAnyDatabase"
            ],
            "_id" : ObjectId("519deedff788eb914bc429b5")
    }
    

提交回复
热议问题