Error with lab - Importing a Dataset (validate_lab_import_dataset)

Hi!

I am having trouble with this lab!

This command is working (opens the mongo shell):
mongo --port 27000 --username “m103-application-user” --password “m103-application-pass”

But this is not working:

mongoimport --db applicationData --collection products --port 27000 --username “m103-application-user” --password “m103-application-pass” --file “/dataset/products.json”

It produces this error:
Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.

The referenced file exists, as this command…
vagrant@m103:/$ tail /dataset/products.json

…produces this output
{"_id":{"$oid":“573f7397f29313caab9a7793”},“sku”:{"$numberLong":“999999800050011”},“name”:“Kodak M863 Red EasyShare 8.2MP Digital Camera with Case and Extra Battery”,“type”:“Bundle”,“regularPrice”:149.97,“salePrice”:149.97}
[…]

I think I created the needed user with the correct rights because calling “db.getUsers” yields this:
[…]
“_id” : “admin.m103-application-user”,
“userId” : UUID(“7c7e6061-6282-4b00-a925-316ca49d0a40”),
“user” : “m103-application-user”,
“db” : “admin”,
“roles” : [
{
“role” : “readWrite”,
“db” : “applicationData”
}
]
[…]

Can anyone help?

1 Like

It worked after adding “–authenticationDatabase admin” but I am a little confused because from reading other posts I was under the impression that this was not a needed parameter!

2 Likes

It’s not required if you don’t have authentication (--auth) enabled.

For the benefit of other students, remember to remove any possible lab answers from previous posts.

Hi @Sebastian_Rucker_91044,

With mongoimport command you are required to use the –authenticationDatabase option. When adding a user, you create the user in a specific database. This database is the authentication database for the user.

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Support Engineer

2 Likes

I’ll have to humbly disagree and say that --authenticationDatabase is as optional as using this same command in mongo. Still sticking to my original comment:

For the avoidance of doubt:

i have the same issue.
telnet cluster0-shard-00-00-jxeqq.mongodb.net 27017 doesnt work for me
Who can fixe that for me?

@Sam_79384 I can’t see how this is the same issue

Yes. so basicaly I just start a introduction on MongoDB and it is ask me to connect to the mongo db server by check if this link http://portquiz.net:27017. work, or may be test
telnet cluster0-shard-00-00-jxeqq.mongodb.net 27017 if succes. but in my case, nothing.
I need help…

I can see on your own thread that you’re now getting help from @Shubham_Ranjan.

Hi @007_jb,

The response is in reference to what we need to do in this particular lab where we have authentication enabled. Of course, when we do not have authentication enabled, the authentication database is out of question.

Hope it helps!

Thanks,
Shubham Ranjan
Curriculum Support Engineer

Hi all,

Firstly thank you for the above comments as they were helpful to a point but now I am struggling with the following error when trying to import dataset:

2020-01-11T22:26:54.106+0000 […] applicationData.products 0B/87.9MB (0.0%)

2020-01-11T22:26:54.630+0000 […] applicationData.products 0B/87.9MB (0.0%)

2020-01-11T22:26:54.632+0000 Failed: error connecting to db server: no reachable servers

2020-01-11T22:26:54.632+0000 imported 0 documents

vagrant@m103:~$

Can anyone help?

Thank you in advance!

Quick update:

I have found a work-around solutions and managed to import the dataset from the m103-admin level, rather than m103-application-user, but the validation script has been approved so will take it as a green light to move forward.

Thank you!

Hi @krasy8,

I’m glad your issue got resolved and you were able to import the dataset.

Since the m103-admin users has root role which is like a superset for the readWrite role that the m103-application-user have.

Please refer our documentation if you want to know more about the built-in-roles.

Hope it helps!

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Services Engineer