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. How to publish a WordPress blog to a static GitLab Pages site

    https://opensource.com/article/18/8/publish-wordpress-static-gitlab-pages-site A long time ago, I se ...

  2. [PHP]如何使用Mobile_Detect来判断访问网站的设备:安卓,平板,电脑

    Mobile_Detect 是一个轻量级的开源移动设备(手机)检测的 PHP Class, 它使用 User-Agent 中的字符串,并结合 HTTP Header,来检测移动设备环境. 这个设备检测 ...

  3. Razor语法(二)

    I:ASP.NET MVC3在Visual Studio 2010中的变化 在VS2010中新建一个MVC3项目可以看出与以往的MVC2发生了很明显的变化. 1.ASP.NET MVC3必要的运行环境 ...

  4. Android 常见内存泄漏的解决方式

    在Android程序开发中.当一个对象已经不须要再使用了,本该被回收时.而另外一个正在使用的对象持有它的引用从而导致它不能被回收.这就导致本该被回收的对象不能被回收而停留在堆内存中,内存泄漏就产生了. ...

  5. iOS 使用 AVCaptureVideoDataOutputSampleBufferDelegate获取实时拍照的视频流

    iOS 使用 AVCaptureVideoDataOutputSampleBufferDelegate获取实时拍照的视频流 可用于实时视频聊天 实时视频远程监控 #import <AVFound ...

  6. php遍历文件夹代码实现

    <?php //遍历文件夹 function my_scandir($dir){ $files = array(); if (is_dir($dir)){ if($handle = opendi ...

  7. Excle中range的一些用法

    以下是一些range的简单用法 Sub aa() '-=============================================== '给B列设置填充颜色为黄色 Range(" ...

  8. 编译ORBSLAM2 build_ros.sh,实现kinect2在ROS环境下运行ORBSLAM2

    //編譯ORBSLAM2 build_ros.sh參考:“http://www.cnblogs.com/bigzhao/p/6635770.html”1.source ~/.bashrc出現問題:ct ...

  9. Windows未能启动,原因可能是最近更改了硬件或软件,解决此问题的步骤

    电脑开机出现显示这样一段文字"Windows未能启动,原因可能是最近更改了硬件或软件,解决此问题的步骤":出现问题的界面是这样的 步骤如下: 1.直接按"Enter&qu ...

  10. PsExec使用

    01. 创建一个 Process Process.FileName ="文件路径及文件名称" Process.Arguments ="\\PC PI地址 -u 用户名 - ...