mongodb-error validating settings: only one positional argument is allowed

24,360

Solution 1

Just a wild guess...

... but the various long options should be specified using --, not -:

mongoimport --host localhost \
            --db roudy123_q \
            --collection LebaneseAmericanUniversity\(Lebanon\).json \
            --file LebaneseAmericanUniversity\(Lebanon\).json \
            --jsonArray

Maybe this particular version of mongoimport is more punctilious about that, and will treat -db ... -collection ... as positional arguments rather than keyword arguments ?

Solution 2

This error can also occur if white spaces are given without a "\" in the path to the file . Ex: This wont work: Error

But this would work :

works fine

Solution 3

If you are getting mongodb-error validating settings: only one positional argument is allowed.

  1. Just put --file path in " ".

2.use / instead of \ in --file path.

  1. Also, put --host in " ".

For example:
Suppose you are trying to import data from your local machine to server (MongoDB Atlas or your MongoDB server or locally) in your collection then follow this:

mongoimport --host "cluster0-shard-00-01-ceax1.mongodb.net:27017" --db <dbname> --type json --file "C:/Users/ranjeet/Downloads/MongoDb project/ranjeet.json" --authenticationDatabase admin --ssl --username <Username> --password <Password> --collection <CollectionName>
Share:
24,360
Roudy Tarabay
Author by

Roudy Tarabay

Updated on June 21, 2021

Comments

  • Roudy Tarabay
    Roudy Tarabay about 3 years

    I just moved to a new laptop which had mongo 3.0.0 I believe. On the new laptop I have mongo 3.0.4. and trying the script that was working on the old laptop is giving me errors. This line is giving me the error.

    mongoimport --host localhost \
                -db roudy123_q \
                -collection LebaneseAmericanUniversity\(Lebanon\).json \
                --file LebaneseAmericanUniversity\(Lebanon\).json \
                --jsonArray
    

    error validating settings: only one positional argument is allowed.

    I googled the error and the only relevant result was the source code of mongoimport. So I guess it has something to do with the new version.

  • Roudy Tarabay
    Roudy Tarabay about 9 years
    I can't believe I wasted several hours on that ugh. Hopefully it will save someone else's time. Thanks.
  • jsbisht
    jsbisht over 8 years
    I got my issue fixed with this. But this syntax used to work for me earlier(till this year start). My batch file broke sometime back. Thanks
  • Albeis
    Albeis over 7 years
    It saved me hours :)