Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot import mongodb

Tags:

import

mongodb

I tried mongo import like this

  1. mongoimport -d test -c foo importfile.json
  2. mongoimport --host localhost --db local --collection lecturer --type json --file temp.json --headerline --upsert

and I've got same error message "Syntax Error: missing ; before statement (shell):1" what's wrong with my code & how to import if my data stored in C:\Documents and Settings\User\Desktop ?? please help, thank's in advance

like image 271
user1052073 Avatar asked Jun 14 '12 22:06

user1052073


People also ask

How do I import a database into MongoDB?

To import data to a MongoDB database, you can use mongoimport to import specific collections data, or you can use mongorestore to import a binary (BSON) full database backup. The exported database file must be stored locally on the same machine as your client.

How do I import a CSV file into MongoDB?

You can use the mongoimport command to import CSV files into a collection using the headerline option. Headerline option notifies the mongoimport command of the first line; to be not imported as a document since it contains field names instead of data.

How do I import a JSON file into MongoDB?

To import JSON file you need to follow the following steps: Step 1: Open a command prompt and give command mongod to connect with MongoDB server and don't close this cmd to stay connected to the server. Step 2: Open another command prompt and run the mongo shell. Using the mongo command.

Can we use MongoDB in Android?

It isn't possible to install MongoDB in android devices because the MongoDB's latest releases doesn't support android device's CPU architecture.


2 Answers

mongoimport is intended to run in command prompt and not in the mongo shell. Try exiting out of the shell and running the command.

like image 165
user1295798 Avatar answered Nov 16 '22 01:11

user1295798


One solution is:

First, in cmd, change to the directory containing mongoexport.exe file, then type your command.

C:\Program Files\MongoDB\Server\3.2\bin> .\mongoexport.exe -d foo -c bar -o output.json
like image 33
Yas Avatar answered Nov 16 '22 00:11

Yas