json - 将数据导入 MongoDB Atlas

标签 json mongodb nosql importerror

尝试导入 JSON 文件

mongodb 版本 -- V3.6.3

shell 版本 3.6

使用此命令连接到集群并导入

mongoimport --host cluster0-shard-00-00-xxm0e.mongodb.net:24537 --db ny --type json --file C:/data/docs/ny.json --jsonArray --authenticationDatabase admin --ssl --username xyz --password mongodb

错误信息
2018-03-03T22:53:45.477-0800    no collection specified
2018-03-03T22:53:45.478-0800    using filename 'ny' as collection
2018-03-03T22:53:46.062-0800    Failed: error connecting to db server: server` returned error on SASL authentication step: bad auth Authentication failed.
2018-03-03T22:53:46.062-0800    imported 0 documents

尝试了几个选项,如
删除 -ssl
添加----sslAllowInvalidCertificates
将“C:/data/docs/ny.json”添加到文件名
这些都不起作用..任何帮助表示赞赏

最佳答案

您必须指定集合 -c or --collection 标志。见官方 docs

mongoimport 
  --host <HOST> 
  --ssl --username <USERNAME> 
  --password <PASSWORD> 
  --authenticationDatabase admin 
  --db <DATABASE> 
  --collection <COLLECTION> 
  --type <FILETYPE> 
  --file <FILENAME>

关于json - 将数据导入 MongoDB Atlas,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49092856/

相关文章:

ruby-on-rails - 响应多个 JSON 渲染。 ( ruby /rails )

javascript - file_put_content 数组结构不起作用

java - Mongodb数据库连接失败

node.js - 如何在 Mongoose 模式中使用项目的值

nosql - ArangoDB 可以像 MongoDB 或 CouchDB 一样扩展吗

mongodb - 如何使用 URI 导出数据库中的所有集合?

javascript - 使用 AngularJS.js 获取下拉列表中的 JSON 数据?

c# - 为 iOS Unity 构建时出现文件路径问题

ruby-on-rails - 如何在 mongoid 中使用或条件进行查询

elasticsearch - elasticsearch查询在简单查询中给出的结果非常慢