Unable to delete collection

When I am trying to execute this query

mongo “mongodb+srv://cluster0-djhy5.mongodb.net/video” --username m001-student --password m001-mongodb-basics loadReviewsDataset.js

I get the following error.

QUERY [js] uncaught exception: Error: drop failed: {
“ok” : 0,
“errmsg” : “user is not allowed to do action [dropCollection] on [video.reviews]”,
“code” : 8000,
“codeName” : “AtlasError”
}

I even gave the user “atlasadmin” but still, it doesn’t work.

Hey @jchakrad

So I ran your connection command without the loadReviewsDataset.js file at the end:

mongo "mongodb+srv://cluster0-djhy5.mongodb.net/video" --username m001-student --password m001-mongodb-basics

Then when I was inside the mongo shell I ran

load('loadReviewsDataset.js')

And everything worked! :slight_smile:

Perhaps you could try this out? Just make sure you start the mongo shell from the same directory that has the loadReviewsDataset.js file. And you should be good to go. If not feel free to get back to me.

Also I just tried this command, which is a slight variation to yours but it worked as well. Notice the < character. And if copying the below command be sure to change the fancy quotes to normal quote or the shell will throw a No digits error

mongo “mongodb+srv://cluster0-djhy5.mongodb.net/video” --username m001-student --password m001-mongodb-basics < loadReviewsDataset.js

Hi @natac13

Yes the file is in the same folder where I am running my mongoshell

I have tried the ways you suggested but non of the work it’s still the same issue.

mongo “mongodb+srv://cluster0-djhy5.mongodb.net/video” --username m001-student --password m001-mongodb-basics<loadReviewsDataset.js

MongoDB shell version v4.2.0

connecting to: mongodb://cluster0-shard-00-00-djhy5.mongodb.net:27017,cluster0-shard-00-01-djhy5.mongodb.net:27017,cluster0-shard-00-02-djhy5.mongodb.net:27017/video --username m001-student?authSource=admin&compressors=disabled&gssapiServiceName=mongodb&replicaSet=Cluster0-shard-0&ssl=true

2019-08-16T17:46:14.793+0530 I NETWORK [js] Starting new replica set monitor for Cluster0-shard-0/cluster0-shard-00-00-djhy5.mongodb.net:27017,cluster0-shard-00-01-djhy5.mongodb.net:27017,cluster0-shard-00-02-djhy5.mongodb.net:27017

2019-08-16T17:46:14.793+0530 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-02-djhy5.mongodb.net:27017

2019-08-16T17:46:14.794+0530 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-01-djhy5.mongodb.net:27017

2019-08-16T17:46:14.794+0530 I CONNPOOL [ReplicaSetMonitor-TaskExecutor] Connecting to cluster0-shard-00-00-djhy5.mongodb.net:27017

2019-08-16T17:46:16.384+0530 I NETWORK [ReplicaSetMonitor-TaskExecutor] Confirmed replica set for Cluster0-shard-0 is Cluster0-shard-0/cluster0-shard-00-00-djhy5.mongodb.net:27017,cluster0-shard-00-01-djhy5.mongodb.net:27017,cluster0-shard-00-02-djhy5.mongodb.net:27017

Implicit session: session { “id” : UUID(“7ad567f0-af3e-4396-8c1d-62419de4e9d5”) }

MongoDB server version: 4.0.12

WARNING: shell and server versions do not match

video

2019-08-16T17:46:20.510+0530 E QUERY [js] uncaught exception: Error: drop failed: {

“ok” : 0,

“errmsg” : “user is not allowed to do action [dropCollection] on [video.reviews]”,

“code” : 8000,

“codeName” : “AtlasError”

} :

_getErrorWithCode@src/mongo/shell/utils.js:25:13

DBCollection.prototype.drop@src/mongo/shell/collection.js:696:15

@(shell):1:1

2019-08-16T17:46:22.259+0530 E QUERY [js] uncaught exception: WriteCommandError({

“ok” : 0,

“errmsg” : “user is not allowed to do action [insert] on [video.reviews]”,

“code” : 8000,

“codeName” : “AtlasError”

}) :

WriteCommandError({

“ok” : 0,

“errmsg” : “user is not allowed to do action [insert] on [video.reviews]”,

“code” : 8000,

“codeName” : “AtlasError”

})

WriteCommandError@src/mongo/shell/bulk_api.js:417:48

executeBatch@src/mongo/shell/bulk_api.js:915:23

Bulk/this.execute@src/mongo/shell/bulk_api.js:1163:21

DBCollection.prototype.insertMany@src/mongo/shell/crud_api.js:314:5

@(shell):1:1

bye

You are connecting to the wrong database.
Connect to “m001 Sandbox”
I did
mongo “mongodb+srv://sandbox-cv53c.mongodb.net/test” --username m001-student --password m001-mongodb-basics loadReviewsDataset.js

By the way, you’re replying to a post that’s more than 7 months old.

2 Likes