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

100 Views Asked by At

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

2

There are 2 best solutions below

0
On BEST ANSWER

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

11
On

Is your users collection in your database or it is a separate collection in different database?

If in same database and If you are connected to your mongodb server,Try this in terminal.

mongodump --db yourDbName --authenticationDatabase yourAuthDb(eg:admin) --username yourUserName --password yourPassword --out /pathToDump