简体   繁体   中英

mongodump against access control

I was trying mongodump to backup some dbs in mongodb and I have auth enabled in my mongodb.

I have one super user with role: "root" and db: "admin" and one with dbOwner for a specific db abc.

I tried this following command

mongodump --username admin --password "xyz" --authenticationDatabase admin


error - Failed: error dumping metadata: error creating directory for metadata file dump/abc: mkdir dump: permission denied

may be I need to use the credentials of the dbOwner but I thought being the super user one can do that.

Pls tell me how to use these two credentials in mongodump command.

You just follow:

Syntax:

mongodump -d <databasename> -o <target directory>

Example:

mongodump -d user -o ./desktop/foldername.

Where: the user is a collection name and -o is an output file and folder name is an where to store in the file.

I had the same issue and I found this answer posted by kallko on Gihtub which helps me.

So to resolve it, you need to add a sudo just before the command and that's it. It works for me.

Hope it helps !

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM