Unable to perform mongoimport

I was trying to perform the exercise at https://university.mongodb.com/mercury/M103/2021_April_27/chapter/Chapter_1_The_Mongod/lesson/5e5454732c05d038621b4aa2/problem in which I need to perform a mongoimport operation to import a json file into the database. I was trying to run it using the command:
mongoimport --file /dataset/products.json --host localhost --port 27000 --db applicationData -c products -u m103-application-user -p m103-application-pass

but it throws me the following error:-
2021-05-05T01:28:36.573+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.

Can someone please explain to me what I am doing wrong here? Thanks.

Hi, Welcome to the MongoDB Community Forum @Ashish_Barua,

It looks like you have missed certain commands in your string along with "" double quotes around the username and password.

Following points should be considered in order to resolve your issue:

  • -u "m103-application-user" -p "m103-application-pass"
  • --authenticationDatabase admin
  • You could also use --drop flag which will delete any existing collection with the same name to avoid the creation of a duplicate one if we run this command twice.

Hope it helps…!

Kind Regards,

1 Like

Thanks Kushagra! I think the missing part was ---authenticationDatabase.


Hi @Ashish_Barua,

We are glad that your issue was resolved.
We wish you Good luck with the rest of the course.


1 Like