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

前端 未结 6 1880
孤独总比滥情好
孤独总比滥情好 2021-02-08 09:35

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

相关标签:
6条回答
  • 2021-02-08 10:01

    I think giving a white spaces in the file name of directory will also contribute to this error.

    0 讨论(0)
  • 2021-02-08 10:05

    If you get this error while inserting fields with --fields, the probable reason might be you are using spaces to do that.

    Both -f and --fields should work in those cases Using Mongo Version 3.0.6

    mongoimport --db logs --collection action_logs --type tsv -f updated_at ,transaction_time ,origin  --file parsed.tsv
    mongoimport --db logs --collection action_logs --type tsv -f updated_at,transaction_time,origin  --file parsed.tsv
    
    0 讨论(0)
  • 2021-02-08 10:07

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

    But this would work :

    0 讨论(0)
  • 2021-02-08 10:13

    None of the above mentioned answers solved my problem but they indeed helped me in figuring out what I was doing wrong.(I am using windows)

    1)using -d instead of --d (shorthand only require one - not two --)

    2)using "" for absolute file path.

    3)Changing \ to / in file path location.

    For example my files location in windows is: C:\kp github\other projects\projectXyz\myFile.csv

    So for me the command that worked was:

    mongoimport -d users -c contacts --type=csv --headerline --file="C:/kp github/other projects/projectXyz/myFile.csv" or

    mongoimport -d users -c contacts --type csv --headerline --file "C:/kp github/other projects/projectXyz/myFile.csv"

    where users is my db name and contacts is my collection name

    0 讨论(0)
  • 2021-02-08 10:16

    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>
    
    0 讨论(0)
  • 2021-02-08 10:22

    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 ?

    0 讨论(0)
提交回复
热议问题