when doing the m103 mongodb course i came across this error when doing the import lab:
user#NHTTPR# mongoimport /dataset/products.json -h localhost:27000 -u m103-application-user -p “m103-application-pass” --authenticationDatabase admin --db applicationData --drop --collection products
2021-04-07T06:19:23.616+0000 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-256": (AuthenticationFailed) Authentication failed.
the solution was to put single quotes (') around the password. instead of double quotes ( or remove the quotes around the password entirely)
mongoimport /dataset/products.json -h localhost:27000 -u m103-application-user -p 'm103-application-pass' --authenticationDatabase admin --db applicationData --drop --collection products
2021-04-07T06:20:25.025+0000 connected to: mongodb://localhost:27000/
2021-04-07T06:20:25.026+0000 dropping: applicationData.products
2021-04-07T06:20:25.423+0000 9966 document(s) imported successfully. 0 document(s) failed to import.
user#NHTTPR#
use single quote or dont use any quotes following works
mongoimport --username m103-application-user --password m103-application-pass --port=27000 --authenticationDatabase admin --db applicationData --drop --collection products /dataset/products.json
Related
Tried taking dump from a remote node and got the following error:
Failed: can't create session: could not connect to server:
connection(): auth error: sasl conversation error: unable to
authenticate using mechanism "SCRAM-SHA-256": (AuthenticationFailed)
Authentication failed.
Tried two methods to take dump from the remote node. But got the same error in both the methods.
# Method 1
mongodump -h remoteip#port -u xxx -p xxx --db xxx --authenticationDatabase xxx
# Method 2
mongodump --uri "mongodb://username:password#remoteip:port/db?authSource=xxx"
How to resolve this?
For me (trying to use mongodump on a single node DB on the same host), using --authenticationDatabase admin did the trick:
mongodump -u root --password 'secret' --authenticationDatabase admin -d mongo-dev -o /tmp/dump-2020-11-27.bson
(courtesy of mongodump from remote node - unable to authenticate using mechanism "SCRAM-SHA-256")
1.If you are using an URI for mongodump command,--authenticationDatabase admin option is equivalent to ?authSource=admin
mongodump --uri "mongodb://[username:password#]host1[:port1][,host2[:port2],...[,hostN[:portN]]][/[database][?options]]"
sample url:
mongodump --uri "mongodb+srv://username1:password1#host1/db1?authSource=admin"
I had the same issue. In my case, the password has special characters. It works with single quote for password:
-p 'my_password'
I had the same problem and solved it using single quotes in the password like this:
--password 'secret'
Was in the same spot that you are, solved it this way:
mongodump --uri "mongodb+srv://username:password#yourmongodbclustersourceurl" --archive \
mongorestore --uri "mongodb+srv://username:password#yourmongodbclusterdestinationurl" --archive \
--nsExclude "admin.system.*"
Needless to mention, you just need to change your username, password and the url in this formula and voila. Good luck.
I am trying to import a CSV data file in my MongoDB collection transaction which I created in the Mongo Db Atlas.
I used the following connection string:
'''
'mongoimport --uri "mongodb+srv://username:password#reportingdata-n8b3j.mongodb.net/ecommerce?retryWrites=true&w=majority" --collection transactions --drop --type csv --headerline --file data.csv''
'''
It shows the following error :
'''
2020-06-11T19:28:03.513+0545 WARNING: ignoring unsupported URI parameter 'retrywrites'
2020-06-11T19:28:05.849+0545 error connecting to host: could not connect to server: connection() : auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AtlasError) Authentication failed.
'''
I am currently using mongo db 4.2
Try using this command, worked for me (you can find the command in the command line tools) also check if your IP is whitelisted, add your current IP.
mongoimport --host atlas-1jjmob-shard-0/reportingdata-shard-00-00.66vlq.mongodb.net:27017,reportingdata-shard-00-01.66vlq.mongodb.net:27017,reportingdata-shard-00-02.66vlq.mongodb.net:27017 --ssl --username admin --password <password> --authenticationDatabase admin --db ecommerce --collection transactions --drop --type csv --headerline --file data.csv
i tried to create a dump of a mongodb database on remote server which is running centos,nginx,mongodb v4.0.18 using the following command..
mongodump --host localhost:27017 --authenticationDatabase admin --username <uname> --password <password> --db <db> --out <path to dump>
but im getting the following error
Failed: error connecting to db server: server returned error on SASL authentication step: Authentication failed.
I just replaced --host localhost:27017 for --port 27017. My db is in localhost too. I omitted --db <db> --out <path to dump> too. I point to my db with the --authenticationDatabase flag.
I hope this helps.
I need to import data from a JSON file to a cluster in Atlas mongodb.
I looked into the documentation and found the following command
mongoimport --host centarosa-shard-0/centarosa-shard-00-00-eplsl.mongodb.net:27017,centarosa-shard-00-01-eplsl.mongodb.net:27017,centarosa-shard-00-02-eplsl.mongodb.net:27017 --ssl --username parvarish --password --authenticationDatabase admin --db --collection --type --file
The error that I am getting is :
Failed: error connecting to db server: no reachable servers
I also tried updating my mongodb version to 4.0.1
But still getting the same error
Please guide me through this.
Thanks
The code provided is missing required arguments. Try the code below, replacing the bolded values with those appropriate for your environment.
mongoimport --host centarosa-shard-0/centarosa-shard-00-00-eplsl.mongodb.net:27017,centarosa-shard-00-01-eplsl.mongodb.net:27017,centarosa-shard-00-02-eplsl.mongodb.net:27017 --ssl --username parvarish --password MYPWD --authenticationDatabase admin --db MYDB --collection MYCOLLECTION --type json --file C:\PATH\IMPORT-FILE.json --jsonArray
Just finished setting up my mongodb and found out that there is a free service called Atlas. Started up a cluster and ran a mongodump and mongorestore as explained here https://www.mongodb.com/blog/post/atlas-on-day-one-importing-data, but can't seem to get it to work.
Here is my shell commands:
mongorestore --ssl --db=infovis --host infovis-shard-00-00-nmctc.mongodb.net:27017,infovis-shard-00-01-nmctc.mongodb.net:27017,infovis-shard-00-02-nmctc.mongodb.net:27017/test?replicaSet=Infovis-shard-0" --authenticationDatabase admin --dir=dump/infovis --username danielbook --password <Password>
What am I doing wrong?
EDIT: Solved the problem by running mongoimport on the server instead.
So, I solved this by using mongoimport instead. I had just created the database in mongo, so I could just use the same csv files and then use
mongoimport -h cluster0-shard-00-00-nmctc.mongodb.net:27017 -d infovis -c flights -u <USER> -p <PASSWORD> --file march_2016.csv --type csv --headerline
for each file I want to import to the Atlas database.