DEV Community

Nagarajan R
Nagarajan R

Posted on

Answer: MongoDB - admin user not authorized

I was also scratching my head around the same issue, and everything worked after I set the role to be root when adding the first admin user.

use admin
db.createUser(
  {
    user: 'admin',
    pwd: 'password',
    roles: [ { role: 'root', db: 'admin' } ]
  }
);
exit;

If you have…

Top comments (0)