Mongoimport command not authenticating

when i am running below mongoimport command in lab it gives me authentication error. which i thought is due to it is trying to authenticate on applicationData database but it needs to authenticate on admin db

mongoimport --host localhost:27000 --username m103-application-user --password m103-application-pass --db applicationData --collection products --file /dataset/products.json

image

but when I change --db parameter to admin it connects but do not import as user does not have write privileges

mongoimport --host localhost:27000 --username m103-application-user --password m103-application-pass --db applicationData --collection products --file /dataset/products.json

image

how to solve the issue

Could you please share the real command you are running?

The little we see from the actual command where there is an error has the parameter

–collection applicationData.products

but you write that you run the command

–db applicationData --collection products*

You have define 2 databases here: authenticationDatabase and db
1st is admin, 2nd is applicationData. It was not explained clear in lesson but explained well in documentation.

p.s:

1 Like

@Ihor_92565 thanks this resolves the issue. I believe they should include a sample command with all necessary parameters.

thanks for the help

You are welcome. Yes, mongodb labs are not straightforward like Oracle. It takes more time than usually with other vendors and require to look for info outside of course lessons.

Hi, when I am defining admin database by “use admin” command, and then db.test.insert ot doesnt work due to lack authority.
How to create admin database in this LAB

This lab does not ask you to insert documents in the test collection in the admin database.

Which step exactly are you trying to do?

Post a screenshot of the step that shows any issue you are having.

Hi
I was unable run the mongoimport command with authentication error.

One of the solution given in this forum is to create two dbs, admin and databaseApplication which are jot pre created hence I tried to create admin db by inserting test document

You should close this thread as your authentication error is being handled in another thread.

To write to the admin database you must authenticate with a user that has write access to the database.

Closing this thread as @Niket_Agrawal is already getting support in this thread : Chapter 1 Last LAB, Authentication failure error