Importing, Exporting, and Querying Data Instructions not working

Hello
I am trying to practice the mongodb-tools but I get the following error.

I’m having difficulties in exporting the data

image

I’d appreciate if someone would offer some help to solve the issue

Thanks

Your connect string is not correct
It should be sandbox.xxxxx.mongodb.net
From where you are trying to take export?
Your own cluster?
Correct the connect string.It will work

1 Like

I still have difficulty in connecting to the Atlas cluster for the course

I try to run the admin database as follows:

sudo mongo "mongodb+srv://sandbox.[...].mongodb.net/admin" --username m001-student

But I get a host of errors about ssl certificate, although I have added my current IP address in the “Network Access” tab.


I am caught in this loop of removing and re-installing mongo for a past couple of days, so any help is appreciated

You are suppose to use IDE for this course
Why you are using your local host?
Why sudo just run as normal user
Please share your connect string
You can always change the pwd later or create a test user and share credentials

The above is insufficient for connecting in the IDE. The IP address of the VM running inside the IDE is not the same as your local machine. For the purpose of this course, it is simpler if you allow connection from anywhere with 0.0.0.0.

Did you connect to a different network after you whitelisted your IP address?
If you have, then that’s where the problem is coming from because different networks have a unique IP address and that’s why we were told to grant access to all network by using the CIDR form 0.0.0.0/0
I hope this solves your problem

Hi @,

Hope your issue has been resolved. Let us know if you are still facing any issues.

~ Shubham

I have the same issue, I have whitelisted IPs by using 0.0.0.0/0 yet still I am getting an error of “no such host”
I am using
mongodump --uri “mongodb+srv://m001-student:xxxxxxx@xxxx.mongodb.net/sample_supplies”

Your URI is wrong.

A valid atlas cluster will have the following form:

ClusterName.SomeRandomLettersAndNumbers.mongodb.net

Yours seems to be missing the ClusterName part.

And don’t bother hiding the URI, it is a free cluster for training. The important part is the password. You can create a temporary password and share the complete URI so we can help better. In this course, you are asked to create a cluster named sandbox, so try with

mongodb+srv://m001-student:m001-password@sandbox.WhatEverValueYouPaintedRed.mongodb.net
2 Likes

Thanks, it worked. I was missing the “sandbox” part, rookie mistake :smiley:

Even if we try using localhost, still it should work right? Considering we have whitelisted 0.0.0.0/0 IP so as to connect from anywhere. Correct me if I’m wrong.

Yes it should work
What error are you getting
Please show screenshot

Hi Ram,

I get Below error. I have provided the ACCESS FROM ANYWHERE IP in network access too. I didn’t change. The only thing I did is installing home-brew and then providing brew install mongodb-database-tools since my terminal didn’t recognise mongoexport command. After installing below error.

CONNECTION:
mongoexport --uri=“mongodb+srv://m001-student:m001-*******@sandbox.*****.mongodb.net/sample_supplies” --collection=sales --out=sales.json

ERROR:

2021-01-15T10:53:06.958+0000 error parsing command line options: error parsing uri: lookup _mongodb._tcp.sandbox.*****.mongodb.net on 192.#.1.#:#: no such host
2021-01-15T10:53:06.959+0000 try ‘mongoexport --help’ for more information

Thanks…

You have to check first if you can connect with that uri from the shell
Only then your mongoexport works

May be your network not supporting SRV type string
Try old style(long form of string) and see

mongodump --uri command works fine and gives expected result. I am able to view the content of metadata json file. The problem is only with the mongoexport command.

I tried even the in-browser IDE, but still the same problem. Also Im not sure about the long form string. Any samples to try?

You do not need to hide the password. If it is different from the one required, the validation script will fail anyway.

You do not need to hide the cluster name. It is a training cluster that should not have anything personnel in it and that can be recreated at any time. Having the real name help us help you.

Most likely you have a typing error in your cluster name. Especially since you confirm that mongodump is working. If one is working with the given URI, then all should be working. Sometimes cut-n-pasting brings invisible characters or mangle the quotes.

:slight_smile: Yeah sure … This is the exact connection I provided.

mongodump --uri “mongodb+srv://m001-student:m001-password@sandbox.qqjf5.mongodb.net/sample_supplies”

mongoexport --uri=“mongodb+srv://m001-student:m001-password@sandbox.qqfj5.mongodb.net/sample_supplies” --collection=sales --out=sales.json

Below result for mongodump command.*

<ent:m001-password@sandbox.qqjf5.mongodb.net/sample_supplies"
2021-01-15T15:10:25.659+0000 writing sample_supplies.sales to
2021-01-15T15:10:26.502+0000 done dumping sample_supplies.sales (5000 documents)
bash-4.4#

Below Result for mongoexport.

bash-4.4#
<godb.net/sample_supplies" --collection=sales --out=sales.json
2021-01-15T15:11:21.076+0000 error parsing command line options: error parsing uri: lookup _mongodb._tcp.sandbox.qqfj5.mongodb.net on 10.81.176.1:53: no such host
2021-01-15T15:11:21.076+0000 try ‘mongoexport --help’ for more information
bash-4.4#

There is definitively a cut-n-paste issue for mongoexport.

If I cut-n-paste your mongoexport command, I have the same error. If I type the URI by hand I do not get the error. I have another issue that I am still trying to figure out.

What is the other issue you got? Also could you please provide the result when you keyed in the URI without copy/paste.

My other issue was that I forgot to add the database name /sample_supplies at the end of my hand-types URI.

While I might say there are issues with cut-n-paste, it is more a question of the source of the cut-n-paste. The following source should be fine as I enclosed the command within 2 triple back ticks (```) lines

mongoexport --uri="mongodb+srv://m001-student:m001-password@sandbox.qqjf5.mongodb.net/sample_supplies" --collection=sales --out=sales.json