Search code examples
mongodbmongodump

how to dump the mongodb collection which has sensitive information using command


i am using mongo db and it has 10 collections and from them one of the collection (system.users) has sensitive information like this

db.system.users.find()

{ "_id" : ObjectId("6572c3c6a9f24c464097225a"), "user" : "admin", "pwd" : "password", "roles" : [ "readWrite", "databaseName" ], "_class" : "com.package.MongoDbConfig$UserCredentials" }

when i am trying to take the mongodump i am getting getting 9 collections only and unable to get the system.users collection.

command

mongodump --host localhost --port 27017 --db database -u admin-p password --out /path

and i tried to run the with credentials also bet getting this issue

mongodump --host localhost --port 27017 --db database --out /path

Error:

Failed: can't create session: failed to connect to mongodb://localhost:27017/: connection() error occurred during connection handshake: auth error: sasl conversation error: unable to authenticate using mechanism "SCRAM-SHA-1": (AuthenticationFailed) Authentication failed

Note: I don't have any password-based authentication to mongo db, it will be directly access

please help me

Thanks


Solution

  • mongodump --host localhost --port 27017 --db database --collection system.users --out /path