0

How to create an Admin user in MongoDB

Hello,I just want to create a user who should have the admin privileges in MongoDb ?What is the format

Mongodb Add a comment
otwol
asked Aug 13 2019
edited Aug 19 2019

Answer

0

Login in to the MongoDB server
$ mongo

use admin;

db.createUser(
  {
    user:"user1",
    pwd:"password",
    roles:[{role:"root",db:"admin"}]
    }
    )
exit

Connect to the MongoDb server using the user1 credentials
$ mongo -u user1 -p --authenticationdatabase admin
Enter the Password of the user that you have set and get connected to the mongoDb server.

Add a comment
linuxhelp
asked Aug 14 2019
Post your Answer