1

I can't import data into my existing database located on mongoDBAtlas. I installed and connected robomongo with mongoDBAtlas for working with atlas.

I created new database jasper and collection User in robomongo then I created user.json file in my project where are stored my data.

I followed tutorial on https://docs.atlas.mongodb.com/import/mongoimport/ - how to use mongoimport with mongodb.

Here is my command, Im typing in terminal:

mongoimport --uri mongodb://Morty:<PASSWORD>@jasper-shard-00-00-mrihb.mongodb.net:27017/jasper?ssl=true&replicaSet=jasper-shard-0&authSource=admin --collection User --drop --file ./src/data/user.json --jsonArray

that give me an error:

[1] 40930
[2] 40931
-bash: --collection: command not found
[2]+  Done                    replicaSet=jasper-shard-0
KSC1-LMC-K00587:Interview-test-part-one marze$ 2017-10-15T10:38:35.209+0200 no collection specified
2017-10-15T10:38:35.209+0200    using filename '' as collection
2017-10-15T10:38:35.209+0200    error validating settings: invalid collection name: collection name cannot be an empty string
2017-10-15T10:38:35.209+0200    try 'mongoimport --help' for more information       

If I run mongoimport for localhost it works perfectly.

Where should be the problem ?

4

1 回答 1

2

解决方案: - 为 uri 参数使用引号。

mongoimport --uri "mongodb://Morty:<PASSWORD>@jasper-shard-00-00-mrihb.mongodb.net:27017/jasper?ssl=true&replicaSet=jasper-shard-0&authSource=admin" --collection User --drop --file ./src/data/user.json --jsonArray
于 2017-10-16T15:47:29.290 回答