Arc*_*aye 13 json mongodb mongoimport
我正在尝试使用mongoimport命令导入json文档,并尝试了所有可能的方法,但它给出了低于错误.Plz告诉我,我在这里做错了什么.我已经给出了json doc的完整路径.我想导入具有800多条记录的大文档,但因为它失败了所以目前我的students.json包含简单的一行{name:"Archana"}但是即使这样也失败了.
C:\data\db>mongo
2016-02-02T17:48:44.788+0530 I CONTROL [main] Hotfix KB2731284 or later update is installed, no need to zero-out data
MongoDB shell version: 3.2.1
connecting to: test
> show collections
names
students
> mondoimport -d test -c students students.json
2016-02-02T17:50:21.001+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < students.json
2016-02-02T17:50:25.840+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < file students.json
2016-02-02T17:50:31.233+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < f students.json
2016-02-02T17:50:35.417+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < f C:\data\db\students.json
2016-02-02T17:50:51.658+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students < f "C:\data\db\students.json"
2016-02-02T17:50:56.897+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -d test -c students C:\data\db\students.json
2016-02-02T17:51:06.849+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:15
> mondoimport -db test -c students C:\data\db\students.json
2016-02-02T17:54:33.545+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:16
> mondoimport --db test --collection students C:\data\db\students.json
2016-02-02T17:56:24.253+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
> mondoimport --db test --collection students --file C:\data\db\students.json
2016-02-02T17:56:33.589+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
> mondoimport --db test --collection students --file C:\data\db\students.json --jsonArray
2016-02-02T17:58:21.131+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
> mondoimport --db test --collection students C:\data\db\students.json --jsonArray
2016-02-02T17:58:32.650+0530 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:14
Run Code Online (Sandbox Code Playgroud)
Aks*_*eth 39
您可能正在mongo shell下运行此命令.正如你在路径中看到的那样,program files/mongodb/server/3.2/bin在mongod下没有mongoimport命令.因此,为了解决问题,请将cmd提示符导航到该文件,而不使用mongo shell(mongo)在cmd提示符下运行该命令.
我试图从mongo shell使用mongoimport.所以答案是"mongoimport是不同的实用程序"所以如果你想使用mongoimport然后在使用"mongod"启动mongo服务器后,使用需要启动不同的cmd并转到C:\ Program Files\MongoDB\Server\3.2\bin或它应该在你的路径,然后你需要运行"mongoimport"命令.如果你从"mongo"shell开始使用"mongoimport",那么它将无法工作.
小智 3
尝试这样。将此代码复制到文本文档中并以 .sh 扩展名保存。将这两个文件放在桌面上并在终端中执行 .sh 文件
mongoimport --db test --collection students --file students.json
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
40782 次 |
| 最近记录: |