OperationFailure: database error: not authorized for query on database.system.namespaces

1.4k Views Asked by At

I am beginner lift with django mongodb on heroku [ addon : mongolab ].

heroku run python manage.py syncdb

Running python manage.py syncdb attached to terminal... up, run.2332 Creating tables ...

OperationFailure: database error: not authorized for query on database.system.namespaces consider editing privileges on the basis of data mongo

.

>use admin
>db.addUser({ user: "myadmin", pwd: "1234", roles: ["userAdminAnyDatabase"] })

but get:

Error: couldn't add user: not authorized on admin to execute command 

Thanks in advance.

3

There are 3 best solutions below

0
phildini On

I think this is more a heroku problem than a django problem. It appears to be that you're not allowed to add users on the mongodb instance; were you send a username and password to plug into the django settings?

0
jmccartie On

Heroku Postgres does not allow for user creation. You'll want to use the connection string provided in DATABASE_URL. Actions like creating/dropping DB's and creating users is prohibited.

0
Ravi On

First you should connect to your mongodb terminal without any authentication, then you try to create user or user-role which you want to do.

check this link for more information. here