Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongoimport : 'error validating settings: only one positional argument is allowed'

Ok so I am trying.... to Importing a dummy JSON file into MongoDB and getting this error, a Google search yields no definitive explanation, and though this topic is already on here, that's more a syntax related error.

I think my syntax is ok, however if it is not please point it out and let me know. Also I think the other issue is my path [format correct] ? or is it something entirely different I am missing.

I don't understand the error and thus can't find a suitable "plain English" explanation anywhere to figure it out myself, so if you have a link please drop it in for me, it will be appreciated....

The error:

$ mongoimport --jsonArray --collection bank_data /Macintosh HD/Users/Tinus/Downloads/bank_data.json/bank_data.json
2016-09-20T13:23:56.592+1200    error validating settings: only one positional argument is allowed

-: Running OSX -: Mongod started -: Using /data/db path and connected to test "All good" -: running mongoimport from separate shell


$ mongo --version MongoDB shell version: 3.2.8

$ mongoimport --jsonArray --collection some_data --file /path/path/data.json
$ mongoimport --jsonArray --collection some_data /path/path/data.json

A) Also when adding --file i get: incompatible options: --file and positional argument(s)

like image 242
Hendrik Avatar asked Sep 20 '16 01:09

Hendrik


Video Answer


2 Answers

Try it like that by quoting your path

$ mongoimport --jsonArray --collection bank_data '/Macintosh HD/Users/Tinus/Downloads/bank_data.json/bank_data.json'  

The error

error validating settings: only one positional argument is allowed

comes from the fact that your path contains a space which results in splitting it into two separate arguments (if not guarded by surrounding quotes)


BTW: Are your sure your path ends with '...bank_data.json/bank_data.json' and not just one 'bank_data.json'?

like image 131
DAXaholic Avatar answered Sep 18 '22 07:09

DAXaholic


~Fix~

A) I changed the path to reed direct from a new folder on root B) For any other’s having the same issue on mac osx —leave out the base root in your path , in my example above it was [ Macintosh HD] the import works without specifying it. thus it was changed to ..

        $ mongoimport --jsonArray --collection bank_data '/Users/Tinus/Downloads/bank_data.json/bank_data.json'

C) Yes the quotes are essential and was also added… D) Remember not to run it inside the mongo shell.

thumbs Up again to DAXaholic

like image 24
Hendrik Avatar answered Sep 18 '22 07:09

Hendrik