Error with lab - Importing a Dataset (validate_lab_import_dataset)


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?


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!


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!

Shubham Ranjan
Curriculum Support Engineer


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 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 work, or may be test
telnet 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!

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


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:

Shubham Ranjan
Curriculum Services Engineer

Hi, mine worked after use the --authenticationDatabase “admin” but I also confuse why doesn’t it authenticate to db “applicationData”?

Is it for authentication it is always refer to “admin”?

Hopefully this will clear your confusion. Thanks

user@M103# mongoimport --port 27000 --authenticationDatabase admin --username m103-application-user --password m103-application-pass --db applicationData --collection products /dataset/products.json
2021-12-10T10:27:57.182+0000 connected to: mongodb://localhost:27000/
2021-12-10T10:27:57.182+0000 0 document(s) imported successfully. 0 document(s) failed to import.
user@M103# ls -lt /dataset/products.json
-rw-r–r-- 1 502 dialout 0 Dec 10 10:26 /dataset/products.json

Everthiing seems cool. But while run test
1 total, 0 passed, 0 skipped:
[FAIL] “The whole dataset was imported”

Did you import the dataset into the ‘products’ collection of the ‘applicationData’ database?

And it says incorrct?

Any idea, in my experience with mongo, i dont find any error as it is clear no data en the json fila an dno data imported with success.

What’s all about this run test?

well with single quotoes con user, pass and file , the run test passed.
mongoimport --port 27000 --authenticationDatabase admin --username ‘m103-application-user’ --password ‘m103-application-pass’ --db applicationData --collection products ‘/dataset/products.json’
weired things.