Added user authentication for MongoDB: added users, deleted users, modified user passwords, read and write permissions, read-only permissions Description: added users operate on the database www.2cto. com1. access the database usedbname2. adding user permissions to the current database is for the current data. add and verify the user useadmindb. addUser (zjx, tsjianx
Add User Authentication for MongoDB: add, delete, modify user password, read and write permissions, read-only permission Description: Add a user to operate on the database www.2cto.com 1. go to the database use dbname 2. adding User Permissions to the current database is for the current data. add and verify the user use admin db. addUser (zjx, tsjianx
MongoDB adds user authentication: adds users, deletes users, modifies user passwords, reads and writes, and read-only permissions.
Note: The added users operate on the database www.2cto.com.
1. Go to the database use dbname
2. Adding User Permissions to the current database is for the current data
1. Add and verify users
> Use admin
> Db. addUser ("zjx", "tsjianxin ")
> Db. auth ("zjx", "tsjianxin ")
2. view existing users
> Db. system. users. find ()
3. Now, you can configure a read/write permission for another database 51cv.
> Use 51cv
> Db. addUser ("51 cvrw", "51cv ")
... "ReadOnly": false...
Www.2cto.com
4. configure a read-only user
> 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
For: mongod dbname-u uname-p password
Mongo admin-u zjx-p tsjianxin
/Usr/local/mongodb/bin/mongo admin-u username-p password -- port number