Reputation: 11
Hi I was going to import a csv dataset into MongoDB here is the code for command line:
mongoimport --type csv --headerline --db mflix --collection movies_initial --host "mflix-shard-0/mflix-shard-00-00-l8vxb.mongodb.net:27017,mflix-shard-00-01-l8vxb.mongodb.net:27017,mflix-shard-00-02-l8vxb.mongodb.net:27017" --authenticationDatabase admin --ssl --username analytics --password analytics-password --file movies_initial.csv
However, I got an error:
Failed: error connecting to db server: server returned error on SASL authentication step: bad auth Authentication failed. 2017-10-29T15:25:25.241-0500 imported 0 documents
Could anyone teach me why this happened?
Upvotes: 0
Views: 2136
Reputation: 1
I am doing similar work and the below code worked for me.
mongoimport --host <CLUSTER>/<SEED_LIST> --ssl --username <USERNAME> --password <PASSWORD> --authenticationDatabase admin --db <DB NAME> --collection <COLLECTION NAME> --type <FILE TYPE> --headerline --file <PATH WITH FILE NAME>
Upvotes: 0
Reputation: 71
when you use attribute --host
then just specify host no need to specify other details.
Try the command below:
mongoimport --type csv --headerline --db mflix --collection movies_initial
--host mflix-shard-00-00-l8vxb.mongodb.net:27017
--authenticationDatabase admin --ssl --username analytics
--password analytics-password --file movies_initial.csv
Upvotes: 1