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

  

Enable Authentication on MongoDB的更多相关文章

  1. mongodb shell和Node.js driver使用基础

    开始: Mongo Shell 安装后,输入mongo进入控制台: //所有帮助 > help //数据库的方法 > db.help() > db.stats() //当前数据库的状 ...

  2. 开启MongoDB客户端访问控制

    参考官方文档:https://docs.mongodb.org/v2.6/tutorial/enable-authentication/ 基于版本:MongoDB 2.6 概览 在MongoDB数据实 ...

  3. MongoDB - Indexing, Replication, and Security

    Introduction of Indexes: 1> Provide high performance 2> Provide efficient execution to queries ...

  4. MongoDB 用户名密码登录

    Mongodb enable authentication MongoDB 默认直接连接,无须身份验证,如果当前机器可以公网访问,且不注意Mongodb 端口(默认 27017)的开放状态,那么Mon ...

  5. Spring Boot中快速操作Mongodb

    Spring Boot中快速操作Mongodb 在Spring Boot中集成Mongodb非常简单,只需要加入Mongodb的Starter包即可,代码如下: <dependency> ...

  6. 详解在Linux中安装配置MongoDB

    最近在整理自己私人服务器上的各种阿猫阿狗,正好就顺手详细记录一下清理之后重装的步骤,今天先写点数据库的内容,关于在Linux中安装配置MongoDB 说实话为什么会装MongoDB呢,因为之前因为公司 ...

  7. Http Authentication Java

    http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-auth.html Http Authentication Overvie ...

  8. MongoDB数据库(一):基本操作

    1.NoSQL的概念 "NoSQL"一词最早于1998年被用于一个轻量级的关系数据库的名字 随着web2.0的快速发展,NoSQL概念在2009年被提了出来 NoSQL最常见的解释 ...

  9. MongoDB中使用的SCRAM-SHA1认证机制

    摘要: 介绍 SCRAM是密码学中的一种认证机制,全称Salted Challenge Response Authentication Mechanism. SCRAM适用于使用基于『用户名:密码』这 ...

随机推荐

  1. axios put and patch

    window.axios.patch('https://fir-3-test-2332e.firebaseio.com/notes/' + this.$route.params.key + '.jso ...

  2. Sense编辑器(Sense Editor)

    Sense编辑器(Sense Editor) 学习了:https://blog.csdn.net/AbnerGong/article/details/50776605 Sense是一个方便的控制台,用 ...

  3. minic 动作句型处理

    #include "lex_define.h" enum keywords_type//代表一些关键字 { loop_for=,//代表for关键字 loop_while,//代表 ...

  4. Node.js abaike图片批量下载Node.js爬虫1.01版

    //====================================================== // abaike图片批量下载Node.js爬虫1.01 // 1.01 修正了输出目 ...

  5. 如何安装MySQL软件

    1 双击EXE进行安装,在"Developer Components(开发者部分)"上左键单击,选择"This feature, and all subfeatures, ...

  6. 使用gradle构建Android时 版本号versionName中嵌入git提交信息

    为什么要这么做   在应用开发的版本迭代过程中,通过版本号并不能快速定位到所对应的代码,导致在后面分析问题追溯对应版本的代码时比较麻烦.   如果代码是通过git来管理的,git的commit id等 ...

  7. winfrom 底层类 验证码

    效果图: watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvdTAxMzgxNjcwOQ==/font/5a6L5L2T/fontsize/400/fill/I ...

  8. python学习准备阶段(环境配置)python解释器的选择

    pycharm提示No Python interpreter configgured for the project ####### 1 点击configure python interpreter ...

  9. Xshell5 破解

    Xshell5激活码 Xshell5激活方式Xshell5破解版 Xshell是一个用于MS Windows平台的强大的SSH,TELNET,和RLOGIN终端仿真软件.它使得用户能轻松和安全地从Wi ...

  10. 09-spring学习-资源访问接口

    目标: 1,掌握Resource接口的使用. 2,掌握ResourceLoader接口的使用. 3,掌握各种资源数据的读取操作. 具体内容: 要想进行资源读取操作,首先想到IO包中提供的操作类. 但是 ...