0

This is driving me nuts.

I just want to move my mongodb to a new computer.

However when I try to do mongodump --db margin_calls i get the error:

Failed: error dumping metadata: error creating directory for metadata file dump\margin_calls: mkdir dump: Access is denied.

So then I tried it with access controls. I made a user on the admin db with userAdminAnyDatabase privileges, I then restarted mongod in --auth mode and started a mongo instance:

mongo -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"

in the docs it says:

"The myUserAdmin user only has privileges to manage users and roles. As myUserAdmin, if you attempt to perform any other operations, such as read from a foo collection in the test database, MongoDB returns an error."

So I then proceed to make user in the database I want to backup with the role: 'backup'

db.createUser({user: "loba", pwd: "abc123", roles: ["backup"]})

And it just throws this error:

Error: couldn't add user: No role named backup@margin_calls :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1267:15
@(shell):1:1

I've been trying this for days now and I'm beginning to get really stressed out, why can't I simply back up my database ?

I'm using mongo 3.2 on windows 10

David Hancock
  • 453
  • 1
  • 11
  • 24

2 Answers2

1

Please try this : mongodb permisssion error

You need to specify the --out option with a path

emme
  • 215
  • 1
  • 8
0

The access control problem you are facing is not of the mongo access. The mongo process doesnot have permission to create folder in your machine. Try running it as root.

sudo mongodump --db margin_calls

or change the owner permission of the directory

sudo chown user:group metadata-directory

If your DB size is large, go for mongo replication. It even defragments the db, saving space.

Akash Dathan
  • 4,348
  • 2
  • 24
  • 45