Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Mongo - How can I find out what roles the user I am connected as has? How can I assign a user full read-write access?

I have been able to connect to my Mongo instance (which is hosted in the cloud at Compose.io -- it is an "addon" through Heroku) from my MacBook terminal command line.

However, I cannot perform any operations. Commands like "show collections" and "show users" fail with a "not authorized" error.

How can I find out what roles the user I am connected as has? Also, how can I add a user with full read-write permissions? Of course I've tried:

db.createUser({
    user: "accountUser",
    pwd: "password",
    roles: [ "readWrite", "dbAdmin" ]
})

but this command fails with couldn't add user: not authorized on my_db to execute command

like image 705
tadasajon Avatar asked Nov 10 '14 15:11

tadasajon


1 Answers

To view information about the current user, run db.getUser() on the user's database. You'll need to check with your MongoDB provider on how they've set up the security to figure out how to add the correct roles to your users.

like image 153
wdberkeley Avatar answered Sep 21 '22 18:09

wdberkeley