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. 【Shell】linux中shell变量$#,$@,$0,$1,$2的含义解释 && set 关键字使用

    linux中shell变量$#,$@,$0,$1,$2的含义解释   摘抄自:ABS_GUIDE 下载地址:http://www.tldp.org/LDP/abs/abs-guide.pdf linu ...

  2. Office 如何下载网页的视频 JWPlayer的内嵌视频

    右击页面空白处,查看页面源代码 在里面搜索mp4或者swf,video,一般网页中的视频都是这些格式,仔细找一定能找到对应的地址 然后复制到迅雷下载即可

  3. swift 使用匿名函数初始化属性

    swift 使用匿名函数初始化属性 匿名函数格式: { //代码体 }() 大括号是定义函数体的,小括号()是调用函数体的. 为什么不写一个函数然后调用函数呢?为何用匿名函数呢? 主要还是代码的简洁性 ...

  4. DataBase 之 拉链表结构设计

    一.概念 拉链表是针对数据仓库设计中表存储数据的方式而定义的,顾名思义,所谓拉链,就是记录历史.记录一个事物从开始,一直到当前状态的所有变化的信息. 在历史表中对客户的一生的记录可能就这样几条记录,避 ...

  5. python求pi的方法

    来自 #_*_ coding=utf-8 *_* ## {{{ http://code.activestate.com/recipes/578130/ (r5) def pi(places=10): ...

  6. ionicframework(二)

    Start building with Ionic! Follow these quick steps and start building high quality mobile apps in m ...

  7. 一个架构合理的UITableView应该是如何的?

    原文: http://www.chentoo.com/?p=200 iOS 开发中,UITableView 应该是最经常使用到的了.完毕一个UITableView应该实现他的DataSource和De ...

  8. spring日志加载代码解析

    项目用的是springmvc+spring+mybatis框架, 配置日志的时候非常简单,仅仅是把commons-logging.log4j,还有slf4j-log4j三个日志相关的jar包导入项目, ...

  9. centOS7 安装redis-3.2.6

    0.下载tar.gz包并解压到某个位置,然后cd进入解压后的目录(redis-3.2.6)下 1.安装 make MALLOC=libc 关于为什么这样做,参考redis-3.2.6目录下的READM ...

  10. 修改select下拉框的下拉按钮

    ie上的下拉框下拉按钮真是太丑了,如何把他自定义一下呢? 首先,把浏览器自带的下拉框去掉:  select::-ms-expand { display: none; } 接下来,用自己喜欢的下拉图片去 ...