Chapter 1: The Mongod - Lab: Importing a Dataset

Hi,

I am trying to execute the following mongoimport command but getting the
error validating settings: only one positional argument is allowed

mongoimport --port 27000 -u m103-application-user -p m103-application-pass –authenticationDatabase admin -d applicationData -c applicationData.products --file “/dataset/products.json”

First of all what do you men by “positional argument”?

I felt any argument with two - (like --) is called positional argument. In that case my command contains two such arguments
–port 27000
–file “/dataset/products.json”
Please correct me if my understanding is incorrect. If my understanding is correct and if we need to pass more than one such positional arguments and then how to achieve this could you please advise.

Thanks in advance.

Regards,
Mahantesh

When unsure, refer to the documentation. See https://docs.mongodb.com/database-tools/mongoimport/.

Hi steevej,

Thanks for pointing me to the documentation to refer. There is no mention of “positional argument” anywhere in the mongodb documentation. At least I could not find. I even tried to search on the internet for this. There is no concrete information around this. I tried all possible combinations of the command but I ended up with no success. You can see my attempts. Any kind of pointers to rectify the error would be a great help. Thanks in advance.

mongoimport --port=27000 --username=m103-application-user --password=m103-application-pass –-authenticationDatabase=admin --db=applicationData --collection=products --file=/dataset/products.json
error validating settings: incompatible options: --file and positional argument(s)

mongoimport --port=27000 --username=m103-application-user --password=m103-application-pass –-authenticationDatabase=admin --db=applicationData --collection=products --file="/dataset/products.json"
error validating settings: incompatible options: --file and positional argument(s)

mongoimport --port=27000 --username=m103-application-user --password=m103-application-pass –-authenticationDatabase=admin --db=applicationData --collection=products --file “/dataset/products.json”
error validating settings: incompatible options: --file and positional argument(s)

mongoimport --port “27000” --username “m103-application-user” --password “m103-application-pass” –-authenticationDatabase “admin” --db “applicationData” --collection “products” --file “/dataset/products.json”
error validating settings: only one positional argument is allowed

mongoimport --port=“27000” --username=“m103-application-user” --password=“m103-application-pass” –-authenticationDatabase=“admin” --db=“applicationData” --collection=“products” --file="/dataset/products.json"
error validating settings: incompatible options: --file and positional argument(s)

mongoimport --port=“27000” --username=“m103-application-user” --password=“m103-application-pass” –-authenticationDatabase=“admin” --db=“applicationData” --collection=“products” --file “/dataset/products.json”
error validating settings: incompatible options: --file and positional argument(s)

mongoimport --port “27000” --username “m103-application-user” --password “m103-application-pass” –-authenticationDatabase “admin” --db “applicationData” --collection “products” --file “/dataset/products.json”
error validating settings: only one positional argument is allowed

mongoimport --port “27000” -u “m103-application-user” -p “m103-application-pass” –authenticationDatabase “admin” -d “applicationData” -c “products” --file “/dataset/products.json”
error validating settings: only one positional argument is allowed

mongoimport --port 27000 -u m103-application-user -p m103-application-pass –authenticationDatabase admin -d applicationData -c products --file /dataset/products.json
error validating settings: only one positional argument is allowed

mongoimport
–port 27000
-u m103-application-user
-p m103-application-pass
–authenticationDatabase admin
-d applicationData
-c products
–file /dataset/products.json
error validating settings: only one positional argument is allowed

Regards,
Mahantesh

Are you using the IDE?

Post a screenshot of the IDE running the command and producing the error message. I have just run the command

and it worked in the IDE.

1 Like

Thanks steevej, it worked. :slightly_smiling_face:

I have noticed that there is something wrong with one of the hyphens in the
–authenticationDatabase
That might be a copy-paste issue.

1 Like

Yes, hyphens and also quotes and double quotes are often a cut-n-paste issue. Specially, when copying from HTML pages that do not have the appropriate markup.

2 Likes