当前位置:网站首页>MongoDB adds permission management
MongoDB adds permission management
2022-08-09 16:03:00 【The sea of clouds valley day】
Foreword:
With the maturity of the columnar storage concept, more and more developers have begun to accept large-scale distributed columnar databases such as mongodb and hbase.In particular, the rapid construction and use of mongodb makes it more popular.I mainly do a test and practice for mongodb permission configuration through the official website instructions.
step1: start mongod service without authentication
mongod --port 27017 --dbpath /data/db1
step2: Client mongo connect without password and set super user (for admin login)
mongo --port 27017
use admindb.createUser( { { user: "myUserAdmin", pwd: "abc123", roles: [ { role: "userAdminAnyDatabase", db: "admin" } ] })
step3: start the mongod service with verification
mongod --auth --port 27017 --dbpath /data/db1
step4: After the administrator mongo logs in, add a user and assign permissions
mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"
use testdb.createUser( { { user: "myTester", pwd: "xyz123", roles: [ { role: "readWrite", db: "test" }, { role: "read", db: "reporting"} ] })
step5: Authorize user to log in and operate form
mongo --port 27017 -u "myTester" -p "xyz123" --authenticationDatabase "test"
db.foo.insert( { x: 1, y: 1 } )
Note: When accessing without permission, the following error will be reported
Reference:
https://docs.mongodb.com/v3.2/tutorial/enable-authentication/
Afterword:
The above is only for simple management of mongodb, and it will not be directly connected to the port by the outside world.But for more systematic permission management, please refer to the official website description
https://docs.mongodb.com/v3.2/tutorial/manage-users-and-roles/
边栏推荐
猜你喜欢

6大论坛,30+技术干货议题,2022首届阿里巴巴开源开放周来了!

C语言程序设计笔记(浙大翁恺版) 第五周:循环控制

A wave of Versailles: assault by the ali interview guide, I've got nine of the Offer

实践数据湖iceberg 第三十八课 spark sql, Procedures语法进行数据治理(小文件合并,清理快照)

运维--常用中间件

shell------常用小工具,sort,uniq,tr,cut

table中 You may have an infinite update loop in a component render function问题解决

基于FPGA的FIR滤波器的实现(2)—采用kaiserord & fir2 & firpm函数设计

DSPE-PEG-Aldehyde,DSPE-PEG-CHO,磷脂-聚乙二醇-醛基MW:1000

spacedesk-notebook, tablet, extended screen-solve the problem that the tablet font is too small
随机推荐
A wave of Versailles: assault by the ali interview guide, I've got nine of the Offer
DBCO-PEG-DSPE,磷脂-聚乙二醇-二苯并环辛炔,在无铜离子的催化下反应
暴雨天,看天翼云如何“快准稳”防涝
概率论基础知识整理 | 概率论的基本概念
A Preliminary Study on Baidu Open Source e-chart
C语言程序设计笔记(浙大翁恺版) 第十周:字符串
大文件上传和下载场景,如何节省成本?
一种基于视频帧差异视频卡顿检测方案
基于FPGA的FIR滤波器的实现(3)—采用Filter Design & Analysis设计
DSPE-PEG-Aldehyde, DSPE-PEG-CHO, Phospholipid-PEG-Aldehyde MW: 1000
ArcGIS在国土空间·城乡规划中的实战应用
【NodeJs篇】关于path 路径模块的学习和使用
【STM32】TCL2543CN 12位11通道ADC芯片stm驱动程序,使用32自带SPI实现
思维导图FreeMind安装问题及简单使用
Startup error: Caused by: org.apache.ibatis.binding.BindingException summary solution
C语言程序设计笔记(浙大翁恺版) 第四周:循环
实践数据湖iceberg 第三十九课 清理快照前后数据文件变化分析
[DevOps] jekins deployment (1)
C语言程序设计笔记(浙大翁恺版) 第二周:计算
概率论基础知识整理 | 随机变量的数字特征