user1189851
user1189851

Reputation: 5041

unexpected identifier error while bulk insert into mongodb

I have a json file and am trying to insert in bulk to mongodb I do mongoimport --host localhost --db testdb --collection testdbjson --username user -- password pass --type json --file /home/pet/mng/json_test.json It gives the following error SyntaxError: Unexpected identifier

Please help!

Upvotes: 1

Views: 2769

Answers (2)

Simon
Simon

Reputation: 19938

I had the exact same error now - I figured it out. I think you have connected to your mongo instance on mongolab first before you wanted to import. You must not connect to mongolab first - disconnect by typing in "exit" in the shell to get back to command prompt. Then issue the mongoimport command again, the import should work this time.

Upvotes: 3

Carlos Rodriguez
Carlos Rodriguez

Reputation: 883

the document mongoimport the correct syntax

mongoimport -host 127.0.0.1 -port 27017 -u user -p pass -collection testdbjson --db testdb --file /home/pet/mng/json_test.json

or

mongoimport -host 127.0.0.1:27017 -u user -p pass -collection testdbjson --db testdb --file /home/pet/mng/json_test.json

Upvotes: 3

Related Questions