如何将数据导入 mongoDB
How to import data into mongoDB
我正在尝试导入 JSON 格式的大型数据文件。我正在使用
mongoimport --db verbs --collection de --file "/Users/marcelbraasch/Downloads/de.json"
导入数据。这正在经历,但是,我收到以下异常:
Failed: (Unauthorized) not authorized on verbs to execute command { insert: "de", ordered: false, writeConcern: { w: "majority" }, $db: "verbs" }
我已经尝试过这样的组合
mongoimport -h localhost:27017 -u 'user' -p 'password' --db verbs --collection de --file "/Users/myname/Downloads/de.json"
但是 none 它起作用了。如果此信息很重要,我的 mongo 实例是 运行 在 docker 容器中。我需要做什么?
找到答案here。这个缺失的关键字是 authenticationDatabase
。对我有用的命令是:
mongoimport --db verbs --collection de --authenticationDatabase admin --username user --password password --drop --file /Users/myname/Downloads/de.json
。
我一直在努力解决同样的问题,添加关键字 --authenticationDatabase 对我有用。
我正在尝试导入 JSON 格式的大型数据文件。我正在使用
mongoimport --db verbs --collection de --file "/Users/marcelbraasch/Downloads/de.json"
导入数据。这正在经历,但是,我收到以下异常:
Failed: (Unauthorized) not authorized on verbs to execute command { insert: "de", ordered: false, writeConcern: { w: "majority" }, $db: "verbs" }
我已经尝试过这样的组合
mongoimport -h localhost:27017 -u 'user' -p 'password' --db verbs --collection de --file "/Users/myname/Downloads/de.json"
但是 none 它起作用了。如果此信息很重要,我的 mongo 实例是 运行 在 docker 容器中。我需要做什么?
找到答案here。这个缺失的关键字是 authenticationDatabase
。对我有用的命令是:
mongoimport --db verbs --collection de --authenticationDatabase admin --username user --password password --drop --file /Users/myname/Downloads/de.json
。
我一直在努力解决同样的问题,添加关键字 --authenticationDatabase 对我有用。