User Tools

Site Tools


mongodb

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Next revision
Previous revision
mongodb [2017/01/05 06:24]
felixonmars created
mongodb [2017/01/06 07:47]
felixonmars
Line 1: Line 1:
-==== Authentication ​(For MongoDB >= 2.4) ====+==== Authentication ====
 === Add A User Administrator as Per Recommended by MongoDB === === Add A User Administrator as Per Recommended by MongoDB ===
 <​code>​ <​code>​
 $ mongo $ mongo
 > db = db.getSiblingDB('​admin'​) > db = db.getSiblingDB('​admin'​)
-> db.addUser({user: "​username",​ pwd: "​password",​ roles: ["​userAdminAnyDatabase"​]})+> db.createUser({user: "​username",​ pwd: "​password",​ roles: ["​userAdminAnyDatabase"​]})
 </​code>​ </​code>​
  
-=== Add A FULL PRIVILEGED User (For Unlocking Full Functionality ​of RockMongo, etc) ===+=== Add A FULL PRIVILEGED User (to unlock full functionality ​of RockMongo, etc) ===
 <​code>​ <​code>​
 $ mongo $ mongo
 > db = db.getSiblingDB('​admin'​) > db = db.getSiblingDB('​admin'​)
-> db.addUser({user: "​username",​ pwd: "​password",​ roles: ["​dbAdminAnyDatabase",​ "​userAdminAnyDatabase",​ "​readWriteAnyDatabase",​ "​clusterAdmin"​]}+> db.createUser({user: "​username",​ pwd: "​password",​ roles: ["​dbAdminAnyDatabase",​ "​userAdminAnyDatabase",​ "​readWriteAnyDatabase",​ "​clusterAdmin"​]})
-</​code>​ +
- +
-==== Authentication (For MongoDB < 2.4) ==== +
-<​code>​ +
-$ mongo +
-> use admin +
-> db.addUser("​username",​ "​password"​)+
 </​code>​ </​code>​
  
mongodb.txt · Last modified: 2017/01/06 07:47 by felixonmars