1. Add and verify the user
> Use admin
> Db.adduser ("Zjx", "Tsjianxin") #添加用户
> Db.auth ("Zjx", "Tsjianxin")
These add users to the previous version of 2.6, and the 2.6 release adds the user and gives permission: View source print?
2 |
Db.createuser ({User: "root", pwd: "Root", Roles:[{role: "ReadWrite", DB: "Admin"}]}) |
2. View existing users
> Db.system.users.find ()
3. Now to configure a user with read and write access to another database 51CV
> Use 51CV
> Db.adduser ("51CVRW", "51CV")
... "readOnly": false ...
4. Configure a user with read-only permissions
> Use 51CV
> Db.adduser ("51cvr", "51CV", True)
> Db.system.users.find ()
... "readOnly": True ...
5. Delete a user
> Use dbname (admin or 51CV, etc)
> Db.system.users.remove ({User: "haha"})
> Db.system.users.find ()
6. User Login Database Test
MONGO Admin-u zjx-p tsjianxin
/usr/local/mongodb/bin/mongo admin-u user name-p password--port port number
Add users to the previous version 2.6, 2.6 later: View source print?
1 |
./bin/mongo-u user-p Password 127.0.0.1:27017/dbname |
<<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<<<<<<<<< <<<<<<<<<<<<<<<<<<<