当前位置:网站首页>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/
边栏推荐
猜你喜欢
随机推荐
Similar image detection method
Startup error: Caused by: org.apache.ibatis.binding.BindingException summary solution
优化代码 —— 减少 if - else
[DevOps] jekins configuration (2)
[LeetCode] 485.最大连续 1 的个数
正则表达式实战:最新豆瓣top250爬虫超详细教程
C语言——void指针、NULL指针、指向指针的指针、常量和指针
DMPE-PEG-Mal Maleimide-PEG-DMPE 二肉豆蔻酰磷脂酰乙醇胺-聚乙二醇-马来酰亚胺
C语言程序设计笔记(浙大翁恺版) 第四周:循环
OpenCV - 图像模板匹配 matchTemplate
概率论基础知识整理 | 随机变量
Dapp系统开发及智能合约部署技术
物联网技术概论:1~7章汇总(西安交通大学)
STSW-LINK00x下载集合,百度云连接
【OpenGL】四、OpenGL入门总结:LearnOpenGL CN教程中关于欧拉角公式推导
约束性统计星号‘*’
Several common registries and their differences
C语言——指针和数组、指针数组和数组指针、指针和二维数组
Docker安装Redis详细步骤
优化软件测试成本的 7 个步骤









