MongoDB增加用户认证: 增加用户、删除用户、修改用户密码、读写权限、只读权限
Jun 07, 2016 pm 05:56 PM阅读原文: 说明:增加用户是针对数据库进行操作 1.进入到数据库 use dbname 2.针对当前数据库添加用户 权限是针对当前数据 1.添加并验证用户 use admin db.addUser("zjx","tsjianxin") db.auth("zjx","tsjianxin") 2.查看已存在的用户 db.system.users.find(
阅读原文:
说明:增加用户是针对数据库进行操作
1.进入到数据库 use dbname
2.针对当前数据库添加用户 权限是针对当前数据
1.添加并验证用户
> use admin
> db.addUser("zjx","tsjianxin")
> db.auth("zjx","tsjianxin")
2.查看已存在的用户
> db.system.users.find()
3.现在来给另一个数据库51cv配置一个读写权限的用户
> use 51cv
> db.addUser("51cvrw","51cv")
..."readOnly" : false...
4.配置一个只读权限的用户
> use 51cv
> db.addUser("51cvr","51cv",true)
> db.system.users.find()
..."readOnly" : true...
5.删除用户
> use dbname (admin or 51cv ,etc)
> db.system.users.remove({user:"haha"})
> db.system.users.find()
6.用户登录数据库测试
for:mongod dbname -u uname -p password
mongo admin -u zjx -p tsjianxin
/usr/local/mongodb/bin/mongo admin -u 用户名 -p 密码 --port 端口号

Hot Article

Hot tools Tags

Hot Article

Hot Article Tags

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics

How to solve the problem that Windows 11 prompts you to enter the administrator username and password to continue?

Is it true that you can be blocked and deleted on WeChat and permanently unable to be added?

How to set router WiFi password using mobile phone (using mobile phone as tool)

Which version is generally used for mongodb?

Tutorial on changing wifi password on mobile phone (simple operation)

How to completely delete TikTok chat history

The difference between nodejs and vuejs

What is the name of the software that can unlock all wifi passwords (recommended mobile software to get connected wifi passwords with one click)
