Issue
I created admin:
> use admin
switched to db admin
> db.createUser(
... {
... user: 'admin',
... pwd: 'password',
... roles: [ { role: 'root', db: 'admin' } ]
... }
... );
Successfully added user: {
"user" : "admin",
"roles" : [
{
"role" : "root",
"db" : "admin"
}
]
}
> exit;
But when I wanted to logged in I get an error:
> use admin
switched to db admin
> db.auth('admin','password');
Error: Authentication failed.
0
I tried also with:
mongo --port 27017 --authenticationDatabase "admin" -u "admin" -p "password"
and:
mongo localhost:27017/admin -u admin -p password
But it also doesn't work.
Solution
After restarting my PC, I was able to log in to mongodb as admin.
Answered By - Weronika Answer Checked By - Candace Johnson (PHPFixing Volunteer)
0 Comments:
Post a Comment
Note: Only a member of this blog may post a comment.