Reputation: 1
mongoexport --host dbhost --port 27017 --db=mms-service --collection=document --type=csv --fields=_id --query='{}' --limit 10 --out exported.csv -u=user.name --authenticationDatabase admin
but i get an error
could not connect to server: connection() error occured during connection handshake: handshake failure: username must contain a '.' separated database.user pair
what is the meaning of the error, it is the issue of the username, a dot in the username?
i also try to add quote to the username: "user.name", 'user.name', same error
Update:
1, also try mongo command, same error
mongo "mongodb://user.name:password@db-host:27017/?authSource=admin"
mongo --host dbhost --port 27017 -u user.name -p password --authenticationDatabase admin
error message:
MongoDB shell version v4.4.13
connecting to: mongodb://dbhost:27017/authSource=admin&compressors=disabled&gssapiServiceName=mongodb
Error: username must contain a '.' separated database.user pair :
connect@src/mongo/shell/mongo.js:374:17
@(connect):2:6
exception: connect failed
exiting with code 1
2, connect the db without auth, then auth by db.auth(), in this way, i can login into the db
mongo --host dbhost -p 27017
db.auth("user.name", "password") -- the quote required
user dbname
show collections
it show the collections.
Upvotes: 0
Views: 1284
Reputation: 63
I came here and saw no answer, and flailed for several hours to find the solution. (feeling very much like this: https://xkcd.com/979/ ).
What ultimately resolved the issue was to add authMechanism='SCRAM-SHA-1' to the MongoClient parameters in python (or the equivalent option for mongo CLI).
In my case this issue appeared after migrating from Mongo engine 3 to engine 4
Upvotes: 0