show dbs gives “Not Authorized to execute command” error

前端 未结 7 1362
暖寄归人
暖寄归人 2020-12-24 13:42

I\'ve spent some time trying to figure out what is wrong but as I could not find out, I decided to ask here.

I am running MongoDB(Windows 64-bit 2008 R2+) version 3.

7条回答
  •  春和景丽
    2020-12-24 14:15

    There are two things,

    1) You can run the mongodb instance without username and password first.

    2) Then you can add the user to the system database of the mongodb which is default one using the query below.

    db.createUser({
      user: "myUserAdmin",
      pwd: "abc123",
      roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
    })
    

    Thanks.

提交回复
热议问题