Chapter 1 Last LAB, Authentication failure error

Getting error in LAB


bash-4.4# mongoimport --port 27000 -u “m103-application-user” -p “m103-application-pass” --drop --db applicationData --file /dataset/products.json

2020-11-03T16:56:06.671+0000 no collection specified
2020-11-03T16:56:06.671+0000 using filename ‘products’ as collection
2020-11-03T16:56:06.674+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism “SCRAM-SHA-1”: (AuthenticationFailed) Authentication failed.


@Niket_Agrawal,

May have to do with --authenticationDatabase admin missed, the rest looks good to me.

Also, double check that the user and password is correct, I happen to remember them being different, but could be wrong.

Hi sir,
The username and password are correct and I also tried by authentication database option still the error is same

That’s strange, I just tried this

mongoimport --port 27000 -u "m103-application-user" -p "m103-application-pass" --drop --db applicationData --file /dataset/products.json --authenticationDatabase admin

And it’s running fine.

You might want to test again, or maybe someone else has a better idea.

Rather that cut-n-pasting, please provide a screenshot. Cut-n-pasting when not done correctly screw up the quotes. A screenshot also allow us to see the context, which, sometimes is as important as the command.

Thanks Sir. This command is working, I rant the same command multiple times earlier but was not working, may be some issue with copy paste.

2020-11-04T23:32:44.820+0000 no collection specified
2020-11-04T23:32:44.820+0000 using filename ‘products’ as collection
2020-11-04T23:32:44.848+0000 connected to: mongodb://localhost:27000/
2020-11-04T23:32:44.849+0000 dropping: applicationData.products
2020-11-04T23:32:45.245+0000 9966 document(s) imported successfully. 0 document(s) failed to import.

Thanks Steve, Issue got resolved. May be issue with copying and pasting command, when i typed in the full command it worked…

Looks good. Alright mate time to move on :slight_smile: