admin管理员组文章数量:1415684
I am trying to import a sample BSON file test.bson
into MongoDB. The server is already running, so I use
mongoimport --db test --collection foo --drop --file test.bson
However, I get the following error:
2016-01-24T13:51:06.126-0500 connected to: localhost
2016-01-24T13:51:06.144-0500 Failed: error processing document #1: invalid character 'è' looking for beginning of value
2016-01-24T13:51:06.144-0500 imported 0 documents
(1) How does one get around this error, invalid character 'è' looking for beginning of value
? What exactly should I do to access the data in test.bson
?
(2) Is there any other way to import data using MongoDB? If I am in the shell and type
$mongo
how can I import json/bson files?
(BSON is a binary representation of JSON with additional type information.)
I am trying to import a sample BSON file test.bson
into MongoDB. The server is already running, so I use
mongoimport --db test --collection foo --drop --file test.bson
However, I get the following error:
2016-01-24T13:51:06.126-0500 connected to: localhost
2016-01-24T13:51:06.144-0500 Failed: error processing document #1: invalid character 'è' looking for beginning of value
2016-01-24T13:51:06.144-0500 imported 0 documents
(1) How does one get around this error, invalid character 'è' looking for beginning of value
? What exactly should I do to access the data in test.bson
?
(2) Is there any other way to import data using MongoDB? If I am in the shell and type
$mongo
how can I import json/bson files?
(BSON is a binary representation of JSON with additional type information.)
Share Improve this question edited Jan 24, 2016 at 18:58 ShanZhengYang asked Jan 24, 2016 at 18:53 ShanZhengYangShanZhengYang 17.7k52 gold badges142 silver badges247 bronze badges 01 Answer
Reset to default 6I think you need mongorestore instead of mongoimport. So try
mongorestore --db test --collection foo --drop test.bson
From the docs:
WARNING:
Avoid using mongoimport and mongoexport for full instance production backups. They do not reliably preserve all rich BSON data types, because JSON can only represent a subset of the types supported by BSON. Use mongodump and mongorestore as described in MongoDB Backup Methods for this kind of functionality.
mongoimport and mongoexport are used with json-like representations of the data (although it also works with CSV and TSV). mongorestore and mongoexport are for bson.
本文标签: javascriptError importing BSON documentMongoDBStack Overflow
版权声明:本文标题:javascript - Error importing BSON document, MongoDB - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1745202882a2647478.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论