Mongodb Atlas: not authorized on admin to execute command

前端 未结 9 1756
小蘑菇
小蘑菇 2021-02-12 17:56

I have a MongoDB Atlas cluster within which I am trying to simply copy a database within the same instance. Unfortunately, every time I try to run db.copyDatabase() or copydb ad

相关标签:
9条回答
  • 2021-02-12 18:24

    just use this version and then copy its link and replace the username and password from your mongodb atlas that have the permision to read and write and it will connect i was also having the same problem spent a lot of time to solve this then i tries 2.2.12 version and it workerd.

    0 讨论(0)
  • 2021-02-12 18:28

    One other cause of this error is being logged in as a different user than the one who started the bad op -- to use db.killOp you need to be logged into the mongo shell as the same user who started the operation.

    On Atlas, database users can utilize the db.killOp() command to kill their own operations. You are correct that an account with atlasAdmin privileges cannot kill operations on the cluster that were not initiated by that account.

    If you authenticate in the mongo shell with the user that the application used to initiate the offending operations, you should then be able to use db.killOp() to kill said operations.

    (source is atlas support ticket)

    0 讨论(0)
  • 2021-02-12 18:35

    In case you have been using mongoose, I solved a similar error updating mongoose to latest version (based on this post).

    0 讨论(0)
  • 2021-02-12 18:39

    In my case I had this issue while trying to connect to mongodb atlas.I removed the error by removing these from the mongdb uri string . ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true

    Original link : mongodb+srv://username:password@hostname/dbname?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true

    After rectification : mongodb+srv://username:password@hostname/dbname

    0 讨论(0)
  • 2021-02-12 18:39

    I ended up asking this question to MongoDB University discussion board. In case anyone comes across this, this is apparently because I am using a free cluster.

    0 讨论(0)
  • 2021-02-12 18:41

    This drove me insane... Turns out the standard link provided by MongoDB was trying to name my default database "admin". Change the link from

    mongodb+srv://username:password@portfoliosite-ezeot.mongodb.net/**admin**?retryWrites=true&w=majority 
    

    to

    mongodb+srv://username:password@portfoliosite-ezeot.mongodb.net/**test**?retryWrites=true&w=majority
    

    You can put any word in for test just not admin. Hope this helps!

    0 讨论(0)
提交回复
热议问题