无法导入 mongodb
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/11041961/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Cannot import mongodb
提问by user1052073
I tried mongo import like this
我试过这样的 mongo 导入
mongoimport -d test -c foo importfile.json
mongoimport --host localhost --db local --collection lecturer --type json --file temp.json --headerline --upsert
mongoimport -d test -c foo importfile.json
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
并且我收到了相同的错误消息“语法错误:缺少;之前的语句(shell):1”我的代码有什么问题以及如果我的数据存储在 C:\Documents and Settings\User\Desktop 中,如何导入?请帮忙,提前致谢
回答by user1295798
mongoimport is intended to run in command prompt and not in the mongo shell. Try exiting out of the shell and running the command.
mongoimport 旨在在命令提示符下运行,而不是在 mongo shell 中运行。尝试退出 shell 并运行命令。
回答by Kriti Singh
mongoimport
is to be run on the terminal and not inside the mongo shell. To run mongoimport
in terminal, you will need to install the same. On ubuntu, you can do :
apt-get install mongo-tools
Hope this helps :)
mongoimport
将在终端上运行,而不是在 mongo shell 内运行。要mongoimport
在终端中运行,您需要安装相同的。在 ubuntu 上,你可以这样做:apt-get install mongo-tools
希望这会有所
帮助:)
回答by Kindson The Genius
I had the same problem and was able to figure it out after a brief struggling and googling. 1. Navigate to the bin directory in command prompt (cd c:..\bin) 2. Run the mongoimport command but you have to specify the full path of your json file. That solves the problem
我遇到了同样的问题,经过短暂的挣扎和谷歌搜索后能够弄清楚。1. 在命令提示符 (cd c:..\bin) 中导航到 bin 目录 2. 运行 mongoimport 命令,但您必须指定 json 文件的完整路径。这解决了问题
回答by Yas
One solution is:
一种解决方案是:
First, in cmd, change to the directory containing mongoexport.exefile, then type your command.
首先,在cmd 中,切换到包含mongoexport.exe文件的目录,然后键入您的命令。
C:\Program Files\MongoDB\Server.2\bin> .\mongoexport.exe -d foo -c bar -o output.json
回答by Sakthikanth
Open the "Mongo/Server/3.4/bin" folder of mongo db in another command window and try again.It Will work.
在另一个命令窗口中打开 mongo db 的“Mongo/Server/3.4/bin”文件夹,然后再试一次。它会起作用。
回答by Krit Pakarat
try to use CSV is a good.
尝试使用 CSV 是一个不错的选择。
mongoimport -d mydb -c things --type csv --file locations.csv --headerline --upsert
You can convert by ms excel.
您可以通过ms excel进行转换。
回答by Rahi Javaid
Open a new terminal or command prompt within the location of the file you want to import and it should work. It will not work on MongoDB shell
在要导入的文件所在的位置打开一个新的终端或命令提示符,它应该可以工作。它不适用于 MongoDB shell