Mongoimport not working with admin

mongoimport --port=27000 --username=m103-application-user --password=m103-application-pass --authenticationDatabase=applicationData --collection=products --file=/vagrant/shared/products.json

It does not work and instead when i use --authenticationDatabase=admin
it connects but says not authorized in test it says not sure even if I am using admin why is it trying to insert into test

Anything I am missing here
error%20importing

When using mongoimport you need to specify both database name and collection name. By default it will create test database and collection name as the name of the file.

authenticateDatabase should be admin because as per lab, you created the user on admin database. The role readWrite was created on applicationData database

So in your command specify db to be applicationData.

1 Like

Thanks Mahesh. Initially it was giving me error when I tried that. But, again I re-tried after adding db to be applicationData and it worked.

Hi !

I just faced kind of the same problem with authentication failures during mongoimport step.

Please specify in the Lab that we have to explicitly set the --authenticationDatabase parameter… :wink:

1 Like

Thanks for that, I was completely baffled why mine was failing after double and triple checking spelling. If any devs happen to read this, I’d really appreciate some clarification of why this is necessary as it seems to me that admin should be implied if not specified.

I am getting , unable to connect to db Server error:
image

Any help in getting around this is appreciated… thanks in advance

Are you sure the server is running at localhost:27000?

Thanks for your probing question, I was missing the “mongod” step and was directly trying to execute the “mongoimport” command.
I was aboe to complete my lab