Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Not able to run mongodump

Tags:

mongodb

I have created two users with below roles on my mongoinstance

use mydb
db.createUser(
  {
    user: "dbUser",
    pwd: "dbPassword",
    roles: [ { role: "dbOwner", db: "mydb" } ]
  }
)


use admin
db.createUser(
  {
    user: "adminUser",
    pwd: "adminPassword",
    roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]
  }
)

MongoDb is up & running using above credentials, Now when i try to take mongodump using below command in terminal

mongodump --host localhost --port 27017 -u dbUser -p dbPassword --authenticationDatabase mydb

i am getting below error, not able to resolve this

connected to: localhost:27017
assertion: 13 not authorized on admin to execute command { getParameter: 1, authSchemaVersion: 1 }

Any idea? where i am doing wrong?

like image 421
Akhil Avatar asked Nov 28 '22 07:11

Akhil


2 Answers

As suggested by @wdberkeley, problem got resolved by passing db name as parameter

below command runs fine

mongodump --host localhost --port 27017 -u dbUser -p dbPassword -d mydb
like image 111
Akhil Avatar answered Jan 05 '23 17:01

Akhil


mongodump is not a Mongo shell command, it's an operating system command.

Just like you run mongo.exe to start the shell from OS prompt, you should run mongodump the same way from OS prompt. Example:

mongodump --host localhost --port 27017 -u dbUser -p dbPassword --authenticationDatabase mydb

Thanks

like image 42
Dineshaws Avatar answered Jan 05 '23 16:01

Dineshaws