PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Wednesday, October 19, 2022

[FIXED] How to logged in to mongodb as admin?

 October 19, 2022     admin, authentication, console, database, mongodb     No comments   

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)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing