Enable Authentication on MongoDB

1、Connect to the server using the mongo shell

mongo mongodb://localhost:27017

  

2、Create the user administrator

Change to the admin database:

use admin

  

db.createUser({user: "Admin",pwd: "Admin123",roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]}
)

  

执行成功显示如下提示:

 

Then disconnect from the mongo shell (Ctrl+D)

3、Enable authentication in mongod configuration file

 编辑mongodb 配置文件:

sudo vim /etc/mongod.conf

  

在 # security: 节点下输入以下内容:

security:authorization: "enabled"

  

4、save the file and restart mongod :

sudo service mongod restart

  

5、 Connect and authenticate as the user administrator

mongo mongodb://localhost:27017

 

use admin

  

db.auth("Admin", "Admin123")

  

6、Finally, create additional users as needed

use BIMDB
db.createUser({user: "myTester",pwd: "xyz123",roles: [ { role: "readWrite", db: "BIMDB" } ]}
)

 

7、use auth on appsetting.json

mongodb://myTester:xyz123@10.100.150.99:27017/BIMDB

  

 

转载于:https://www.cnblogs.com/autohome7390/p/10096713.html

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/278706.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

windows驱动程序编写_如何在Windows中回滚驱动程序

windows驱动程序编写Updating a driver on your PC doesn’t always work out well. Sometimes, they introduce bugs or simply don’t run as well as the version they replaced. Luckily, Windows makes it easy to roll back to a previous driver in Windows 10. Here’s…

在Windows 7中的Windows Media Player 12中快速预览歌曲

Do you ever wish you could quickly preview a song without having to play it? Today we look at a quick and easy way to do that in Windows Media Player 12. 您是否曾经希望无需播放就可以快速预览歌曲? 今天,我们探讨一种在Windows Media Play…

Vue.js中的8种组件间的通信方式;3个组件实例是前6种通信的实例,组件直接复制粘贴即可看到运行结果

文章目录一、$children / $parent二、props / $emit三、eventBus四、ref五、provide / reject六、$attrs / $listeners七、localStorage / sessionStorage八、Vuex实例以element ui为例。例子从上往下逐渐变复杂(后面例子没有删前面的无用代码,有时间重新…

不可思议的混合模式 background-blend-mode

本文接前文:不可思议的混合模式 mix-blend-mode 。由于 mix-blend-mode 这个属性的强大,很多应用场景和动效的制作不断完善和被发掘出来,遂另起一文继续介绍一些使用 mix-blend-mode 制作的酷炫动画。 CSS3 新增了一个很有意思的属性 -- mix-…

如何更改从Outlook发送的电子邮件中的“答复”地址

If you’re sending an email on behalf of someone else, you might want people to reply to that person instead of you. Microsoft Outlook gives you the option to choose a different default Reply address to cover this situation. 如果您要代表其他人发送电子邮件&…

在Windows 7或Vista资源管理器中禁用缩略图预览

If you want to speed up browsing around in explorer, you might think about disabling thumbnail previews in folders. 如果要加快在资源管理器中的浏览速度,可以考虑禁用文件夹中的缩略图预览。 Note that this works in Windows 7 or Vista 请注意&#xf…

mysql 表数据转储_在MySQL中仅将表结构转储到文件中

mysql 表数据转储For this exercise, we will use the mysqldump utility the same as if we were backing up the entire database. 在本练习中,我们将像备份整个数据库一样使用mysqldump实用程序。 Syntax: 句法: mysqldump -d -h localhost -u root -…

lenos快速开发脚手架

2019独角兽企业重金招聘Python工程师标准>>> lenos一款快速开发模块化脚手架, lenos(p为spring boot版本扩展名)一款快速开发模块化脚手架,采用spring bootspringSpringMvcmybatisshiroswaggerehcachequartzfreemarkerlayui技术开发&#xff…

火狐ok谷歌适配_“ OK Google”在锁定手机上的安全性越来越高

火狐ok谷歌适配If you use “OK Google” to invoke the Assistant on your phone, things are about to change. Google is removing the “Unlock with Voice Match” feature, so the Assistant is going to get a lot more secure. 如果您使用“确定Google”在手机上调用助…

angular ng-zorro 用组件自身方的法来重置表单校验

官网文档的API并没有提供对应的重置表单校验函数の说明,在控制台打印this.validateForm(校验表单对象) 往往我们只关注亮色函数、属性,而这次重置函数藏在__prop__中! 激动万分的使用 this.validateForm.reset()&…

Django用户注册、登录、注销(一)

使用Django自带的用户认证系统编写认证、登录、注销基本功能 功能: 使用Django默认的User表 1)注册 判断是否已存在此用户,存在的话提示报错“用户已存在”; 判断两次输入的密码是否一致,不一致的话提示报错“密码不一…

如何在PowerPoint中自动调整图片大小

PowerPoint can automatically resize an image to fit a shape. You can also resize multiple images already in your presentation to all be the same size. Here’s how it works. PowerPoint可以自动调整图像大小以适合形状。 您还可以将演示文稿中已有的多个图像调整为…

如何在不支付Adobe Photoshop费用的情况下处理Camera Raw

You might think that you need expensive software to take advantage of Camera RAW—something like Photoshop or the more modestly priced Lightroom. Fortunately there is freeware that can help you achieve professional results without professional costs. 您可能…

eclipse 代码提示后面的百分比是什么意思?

简而言之,就是提示你其他人(开发人员)在此情形下使用该方法百分比,最常用方法百分比 见http://www.eclipse.org/recommenders/manual/#d0e32 Call Completion The Call Completion engine, for example, provides you with recomm…

travis-cli 使用

1. 添加项目登录 travis 选择对应项目即可 2. 添加持续集成文件.travis.ymllanguage: node_js node_js:- "node" before_install: - npm install -g jspm - jspm install script: - jspm bundle lib/main --inject备注:这是一个jspm 项目 3. 构建travis 是…

在Windows Media Center中收听超过100,000个广播电台

A cool feature in Windows 7 Media Center is the ability to listen to local FM radio. But what if you don’t have a tuner card that supports a connected radio antenna? The RadioTime plugin solves the problem by allowing access to thousands of online radio …

IntelliJ IDEA——数据库集成工具(Database)的使用

idea集成了一个数据库管理工具,可以可视化管理很多种类的数据库,意外的十分方便又好用。这里以oracle为例配置。 1、配置 在窗口的右边有个Database按钮,点击。 如果没有,请点击上方的View(视图)-Tool Windows(工具窗口)-Database…

代码评审会议_如何将电话会议(和访问代码)另存为联系人

代码评审会议Dialing a conference call doesn’t have to be a tedious process. Your iPhone or Android phone can automatically dial into the call and enter a confirmation code for you. You just have to create a special type of contact. 拨打电话会议不一定是一个…

使用iOS 4越狱iPhone或iPod Touch

In case you haven’t heard the news over the past couple of days, there is now an incredibly easy way to jailbreak your iPod Touch or iPhone running iOS 4. Here we will take a look at how easy the process is. 如果您在过去的几天里没有听到这个消息&#xff0c…

在Windows 7中禁用或修改Aero Peek的“延迟时间”

Are you looking for an easy way to modify the “delay time” for Aero Peek in Windows 7 or perhaps want to disable the feature altogether? Then see how simple it is to do either with the Desktop Peek Tweak. 您是否正在寻找一种简便的方法来修改Windows 7中Aer…