惯性聚合 高效追踪和阅读你感兴趣的博客、新闻、科技资讯
阅读原文 在惯性聚合中打开

推荐订阅源

博客园 - Franky
C
CXSECURITY Database RSS Feed - CXSecurity.com
S
Schneier on Security
Know Your Adversary
Know Your Adversary
Security Latest
Security Latest
Spread Privacy
Spread Privacy
Project Zero
Project Zero
T
The Exploit Database - CXSecurity.com
cs.AI updates on arXiv.org
cs.AI updates on arXiv.org
AI
AI
N
News | PayPal Newsroom
A
Arctic Wolf
NISL@THU
NISL@THU
W
WeLiveSecurity
Security Archives - TechRepublic
Security Archives - TechRepublic
Hacker News: Ask HN
Hacker News: Ask HN
P
Palo Alto Networks Blog
Hacker News - Newest:
Hacker News - Newest: "LLM"
大猫的无限游戏
大猫的无限游戏
L
Lohrmann on Cybersecurity
Last Week in AI
Last Week in AI
T
Threatpost
The Last Watchdog
The Last Watchdog
博客园_首页
C
Cybersecurity and Infrastructure Security Agency CISA
酷 壳 – CoolShell
酷 壳 – CoolShell
量子位
Engineering at Meta
Engineering at Meta
爱范儿
爱范儿
aimingoo的专栏
aimingoo的专栏
S
Security Affairs
P
Privacy & Cybersecurity Law Blog
B
Blog RSS Feed
AWS News Blog
AWS News Blog
P
Proofpoint News Feed
雷峰网
雷峰网
T
Tenable Blog
Schneier on Security
Schneier on Security
H
Heimdal Security Blog
V2EX - 技术
V2EX - 技术
V
V2EX
Exploit-DB.com RSS Feed
Exploit-DB.com RSS Feed
S
Secure Thoughts
Latest news
Latest news
Help Net Security
Help Net Security
Jina AI
Jina AI
Stack Overflow Blog
Stack Overflow Blog
The Cloudflare Blog
V
Vulnerabilities – Threatpost
cs.CL updates on arXiv.org
cs.CL updates on arXiv.org

博客园 - 阿龍

FW:Software Testing What is the difference between modified duration, effective duration and duration? Netezza External Tables --How to use local files in external table How to push master to QA branch in GIT FTPS Firewall Query performance optimization of Vertica (Forward)5 Public Speaking Tips That'll Prepare You for Any Interview (转)The remote certificate is invalid according to the validation procedure Change - Why we need coding standards (转)测试用例编写规范 (转)测试用例模板(Test Case Template) (转)Facebook如何提高软件质量? 敏捷问题小结 (转)RACI模型(RACI Model) (转)Part 2 - Basic of mocking with Moq (转)MongoDB——安装篇(windows) (转)MongoDB设置访问权限、设置用户 赎回收益率(Yield to Call,YTC) YTC, YTM, YTW
(转)MongoDB 增加用户 删除用户 修改用户 读写权限 只读权限,
阿龍 · 2011-10-29 · via 博客园 - 阿龍

MongoDB  增加用户 删除用户  修改用户  读写权限 只读权限,

MongoDB用户权限分配的操作是针对某个库来说的。--这句话很重要。

1、 进入ljc 数据库:      

use ljc;              --ljc为数据库名称。

2、添加用户(读写权限,readOnly-->false):

 db.addUser("java","java");

3、 查看一下所有的用户

db.system.users.find();


{ "_id" : ObjectId("4e02a89fb841deb5fda3e5e2"), "user" : "java", "readOnly" : fa
lse,
"pwd" : "59cf7cc156874cbd35cb00869126f569" }

4、用户授权。

db.auth("java","java");

1                                         显示为1 表示授权成功,0表示不成功。


 
5、 添加用户(只读权限,readOnly-->true):

db.addUser("java1","java1",true);

db.system.users.find();
{ "_id" : ObjectId("4e02a89fb841deb5fda3e5e2"), "user" : "java", "readOnly" : fa
lse,
"pwd" : "59cf7cc156874cbd35cb00869126f569" }
{ "_id" : ObjectId("4e02aae6b841deb5fda3e5e3"), "user" : "java1", "readOnly" : t
rue
, "pwd" : "fca6bda05c87a72cce0a4a6458d1e266" }

注意上面标红的位置的readOnly 只读于可写是有区别的。

6、更改密码(为已经存在的用户更改密码):

 db.addUser("java","java1");

7、删除用户:

db.system.users.remove({user:"java1"});

关于库权限,如果用户需要全局的权限,可以在admin和local的两个库里添加,但是需要重启库,

有待验证。