0
votes

I need to import data from a JSON file to a cluster in Atlas mongodb.

I looked into the documentation and found the following command

mongoimport --host centarosa-shard-0/centarosa-shard-00-00-eplsl.mongodb.net:27017,centarosa-shard-00-01-eplsl.mongodb.net:27017,centarosa-shard-00-02-eplsl.mongodb.net:27017 --ssl --username parvarish --password --authenticationDatabase admin --db --collection --type --file

The error that I am getting is :

Failed: error connecting to db server: no reachable servers

I also tried updating my mongodb version to 4.0.1 But still getting the same error

Please guide me through this.

Thanks

1
First thing I'd check would be the network whitelist (in the atlas security section) to make sure you're connecting from a computer with an IP that's allowed to connect.willis
Hi Willis, I have added 0.0.0.0/0 in my IP Whitelist..So that shouldn't be a problemParvarish

1 Answers

0
votes

The code provided is missing required arguments. Try the code below, replacing the bolded values with those appropriate for your environment.

mongoimport --host centarosa-shard-0/centarosa-shard-00-00-eplsl.mongodb.net:27017,centarosa-shard-00-01-eplsl.mongodb.net:27017,centarosa-shard-00-02-eplsl.mongodb.net:27017 --ssl --username parvarish --password MYPWD --authenticationDatabase admin --db MYDB --collection MYCOLLECTION --type json --file C:\PATH\IMPORT-FILE.json --jsonArray