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

前端 未结 6 840
暗喜
暗喜 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:54

    For MongoDB version 2.6 use:

    db.createUser(
    {
       user: "testUser"
       pwd: "password",
       roles: [{role: "readWrite", db:"yourdatabase"}]
    })
    

    See the docs

提交回复
热议问题