Lab: Lab: Importing a Dataset

Hi all
I am facing some issues with the lab.

  1. When i try to use mongoimport command I am seeing error message
    <-db applicationData --collection products --file /dataset/products.json
    2021-03-09T17:20:38.861+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.

  2. When i connect via mongo command with right username and password and port then i am logged but unauthenticated
    also i am trying to get authenticated by using db.auth() and i am seeing errors.

Bellow after login
db.stats()
{
“ok” : 0,
“errmsg” : “not authorized on test to execute command { dbstats: 1.0, scale: undefined, lsid: { id: UUID(“bf908285-98ce-4fc7-b010-921cc211c570”) }, $db: “test” }”,
“code” : 13,
“codeName” : “Unauthorized”
}

db.auth(“m103-application-user”, “m103-application-pass”)
Error: Authentication failed.
0

Could you please advice what i can do in this case?

Regards

You have to specify the admin as the authentication database on the command line and from the shell you must use admin before db.auth().

I already tried that
use admin
switched to db admin

db.auth(“m103-application-user”, “m103-application-pass”)
Error: Authentication failed.
0

I see 2 possible things. You are not connected to the appropriate instance. Or, the quotes are wrong. It happens when cut-n-pasting from a badly formatted page.

The following quotes are correct.

db.auth( "m103-application-user" , "m103-application-pass" )

The following are wrong.

db.auth( “m103-application-user” , “m103-application-pass” )

4 Likes

Thanks for the suggestion!
I see after replacing double quotes with single quotes it worked.
Interesting why it happens with double quotes and they are not exactly expected characters.
However it works.

Cheers

1 Like

HI I am running following command and getting error to open /data

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

021-03-11T19:22:30.767+0000 Failed: open “/dataset/products.json”: no such file or directory
2021-03-11T19:22:30.767+0000 0 document(s) imported successfully. 0 document(s) failed to import.

I also changed permission of products.jason and still not working. Please suggest

I could suggest you, first try to replace double quotes with single one. Also do not change any file permissions.

Thanks single quotes worked

1 Like

Hi @Miroslav_Asenov and @Mahrukh_Khan

I’m happy that you both were able to find out the solution of the given problem.
If you still have any questions feel free to mention them down here. We are here to make your learning experience more interesting.

Thanks @steevej for helping out learners. Appreciated :clap:

Regards,
Kushagra

1 Like