Dror
Dror

Reputation: 5495

authenticationDatabase error when running mongoimport

when doing the m103 mongodb course i came across this error when doing the import lab:

user@NHTTPR# mongoimport /dataset/products.json -h localhost:27000 -u m103-application-user -p “m103-application-pass” --authenticationDatabase admin --db applicationData --drop --collection products

2021-04-07T06:19:23.616+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-256": (AuthenticationFailed) Authentication failed.

Upvotes: 0

Views: 951

Answers (2)

Deepak Yadav
Deepak Yadav

Reputation: 1772

use single quote or dont use any quotes following works

mongoimport --username m103-application-user --password m103-application-pass --port=27000 --authenticationDatabase admin --db applicationData --drop --collection products /dataset/products.json

Upvotes: 0

Dror
Dror

Reputation: 5495

the solution was to put single quotes (') around the password. instead of double quotes ( or remove the quotes around the password entirely)

mongoimport /dataset/products.json -h localhost:27000 -u m103-application-user -p 'm103-application-pass' --authenticationDatabase admin --db applicationData --drop --collection products 2021-04-07T06:20:25.025+0000 connected to: mongodb://localhost:27000/ 2021-04-07T06:20:25.026+0000 dropping: applicationData.products 2021-04-07T06:20:25.423+0000 9966 document(s) imported successfully. 0 document(s) failed to import. user@NHTTPR#

Upvotes: 3

Related Questions