MongoDB adds user authentication: adds users, deletes users, modifies user passwords, and reads and writes.

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.