Tried to load the file and getting error

I am running mongo connection string from the directory where I have loadMovieDetailsDataset.js /Users/poornimachinnaraj/M001/loadMovieDetailsDataset

Error:

MongoDB Enterprise Cluster0-shard-0:PRIMARY> load(‘loadMovieDetailsDataset.js’)
2020-04-02T18:53:23.014-0500 E QUERY [js] [src/mongo/shell/utils.js:25:13] Error: drop failed: {
“operationTime” : Timestamp(1585871598, 1),
“ok” : 0,
“errmsg” : “not authorized on video to execute command { drop: “movieDetails”, lsid: { id: UUID(“f5c7313a-3b89-4a78-8783-1d6e34abe772”) }, $clusterTime: { clusterTime: Timestamp(1585871588, 1), signature: { hash: BinData(0, 677918017E937F9C770EFACEE11B894990A0B960), keyId: 6763648209215553537 } }, $db: “video” }”,
“code” : 13,
“codeName” : “Unauthorized”,
“$clusterTime” : {
“clusterTime” : Timestamp(1585871598, 1),
“signature” : {
“hash” : BinData(0,“3qlC+VL4Jed7Xl6F5Ym11NLiYFY=”),
“keyId” : NumberLong(“6763648209215553537”)
}
}
}
Stack trace:

connection string:

mongo “mongodb://m001-student:m001-mongodb-basics@cluster0-shard-00-00-jxeqq.mongodb.net:27017,cluster0-shard-00-01-jxeqq.mongodb.net:27017,cluster0-shard-00-02-jxeqq.mongodb.net:27017/test?authSource=admin&replicaSet=Cluster0-shard-0&ssl=true&readPreference=primary” --authenticationDatabase admin --ssl --username m001-student --password m001-mongodb-basics

Please use your Sandbox cluster to load the file
You are trying on Class cluster which is a read only DB.Hence not authorized message

I am not sure if I understood that ryt. I mean where am I making the mistake?

Sandbox cluster is your own cluster where you can load,create your DBs/collections
You must be having a chapter/lab
Create an Atlas Sandbox Cluster

I did follow the steps and did create a Sandbox cluster and it is active in atlas. but when trying to connect and load data from shell , facing so many issues…

What is your Sandbox connect string?
What you pasted is Class cluster string
So please use correct string and load.It will work

1 Like

poornimas-MacBook-Pro:~ poornimachinnaraj$ mongo “mongodb://sandbox-ndxaf.mongodb.net/test” --username m001-student --password m001-mongodb-basics
MongoDB shell version v4.0.17
connecting to: mongodb://sandbox-ndxaf.mongodb.net:27017/test?gssapiServiceName=mongodb

*** It looks like this is a MongoDB Atlas cluster. Please ensure that your IP whitelist allows connections from your network.

2020-04-02T21:11:14.434-0500 E QUERY [js] Error: couldn’t connect to server sandbox-ndxaf.mongodb.net:27017, connection attempt failed: HostNotFound: Could not find address for sandbox-ndxaf.mongodb.net:27017: SocketException: Host not found (authoritative) :
connect@src/mongo/shell/mongo.js:344:17
@(connect):2:6
exception: connect failed
poornimas-MacBook-Pro:~ poornimachinnaraj$

I really have no idea of what is going wrong…because I just copied the connection string from atlas cluster and trying to connect. but still getting error…

mongo “mongodb://Sandbox-shard-0/sandbox-shard-00-00-ndxaf.mongodb.net:27017,sandbox-shard-00-01-ndxaf.mongodb.net:27017,sandbox-shard-00-02-ndxaf.mongodb.net:27017/test? --ssl --username m001-student --password m001-mongodb-basics --authenticationDatabase admin

will this be the correct connection string?

Please try this

mongo “mongodb://sandbox-shard-00-00-ndxaf.mongodb.net:27017,sandbox-shard-00-01-ndxaf.mongodb.net:27017,sandbox-shard-00-02-ndxaf.mongodb.net:27017/test?replicaSet=Sandbox-shard-0” --ssl --authenticationDatabase admin --username m001-student --password m001-mongodb-basics

poornimas-MacBook-Pro:~ poornimachinnaraj$ mongo “mongodb://sandbox-shard-00-00-ndxaf.mongodb.net:27017,sandbox-shard-00-01-ndxaf.mongodb.net:27017,sandbox-shard-00-02-ndxaf.mongodb.net:27017/test?replicaSet=Sandbox-shard-0” --authenticationDatabase admin --username m001-student --password m001-mongodb-basics
MongoDB shell version v4.2.0
2020-04-02T21:56:48.840-0500 F - [main] exception: No digits
2020-04-02T21:56:48.840-0500 E - [main] exiting with code 1
poornimas-MacBook-Pro:~ poornimachinnaraj$

I can connect

Please use double quotes for the string
It shows as inverted commas which will not work

Also for your srv string to work please whitelist your IP

Hi @PoornimaChinnaraj0909,

Are you able to connect using this connection string ?

mongo "mongodb+srv://sandbox-ndxaf.mongodb.net" -u m001-student -p m001-mongodb-basics

~ Shubham