Mongodb Atlas: not authorized on admin to execute command

前端 未结 9 1921
情书的邮戳
情书的邮戳 2021-02-12 18:08

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:28

    I had the same issue when I was trying to connect to a cluster with Node.js version 3.0 or later and using the link below:

    mongodb+srv://username:password@cluster0-eoowo.mongodb.net/test?retryWrites=true

    By selecting version 2.2.12 or later and using the link provided, everything went well

    mongodb://username:password@cluster0-shard-00-00-eoowo.mongodb.net:27017,cluster0-shard-00-01-eoowo.mongodb.net:27017,cluster0-shard-00-02-eoowo.mongodb.net:27017/test?ssl=true&replicaSet=Cluster0-shard-0&authSource=admin&retryWrites=true

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

    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:30

    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:37

    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:38

    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)
  • 2021-02-12 18:38

    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)
提交回复
热议问题