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
Enable Authentication on MongoDB的更多相关文章
- mongodb shell和Node.js driver使用基础
开始: Mongo Shell 安装后,输入mongo进入控制台: //所有帮助 > help //数据库的方法 > db.help() > db.stats() //当前数据库的状 ...
- 开启MongoDB客户端访问控制
参考官方文档:https://docs.mongodb.org/v2.6/tutorial/enable-authentication/ 基于版本:MongoDB 2.6 概览 在MongoDB数据实 ...
- MongoDB - Indexing, Replication, and Security
Introduction of Indexes: 1> Provide high performance 2> Provide efficient execution to queries ...
- MongoDB 用户名密码登录
Mongodb enable authentication MongoDB 默认直接连接,无须身份验证,如果当前机器可以公网访问,且不注意Mongodb 端口(默认 27017)的开放状态,那么Mon ...
- Spring Boot中快速操作Mongodb
Spring Boot中快速操作Mongodb 在Spring Boot中集成Mongodb非常简单,只需要加入Mongodb的Starter包即可,代码如下: <dependency> ...
- 详解在Linux中安装配置MongoDB
最近在整理自己私人服务器上的各种阿猫阿狗,正好就顺手详细记录一下清理之后重装的步骤,今天先写点数据库的内容,关于在Linux中安装配置MongoDB 说实话为什么会装MongoDB呢,因为之前因为公司 ...
- Http Authentication Java
http://docs.oracle.com/javase/7/docs/technotes/guides/net/http-auth.html Http Authentication Overvie ...
- MongoDB数据库(一):基本操作
1.NoSQL的概念 "NoSQL"一词最早于1998年被用于一个轻量级的关系数据库的名字 随着web2.0的快速发展,NoSQL概念在2009年被提了出来 NoSQL最常见的解释 ...
- MongoDB中使用的SCRAM-SHA1认证机制
摘要: 介绍 SCRAM是密码学中的一种认证机制,全称Salted Challenge Response Authentication Mechanism. SCRAM适用于使用基于『用户名:密码』这 ...
随机推荐
- 使用FreeMarker的Web Project例子
1 创建一个名为FreemarkerDemo的Web Project 2 删除index.jsp,新建index.html,index.html中的内容为: <html> <head ...
- 使用rsync进行多服务器同步
使用rsync进行多服务器同步 @(Others) 当集群数量很大时,修改配置文件和节点之间的文件同步是一件很麻烦且浪费时间的事情. rsync是linux上实现不同机器之间文件同步.备份的工具,ce ...
- js 倒计时跳转页面
<script type="text/javascript">var i = 5; var intervalid; intervalid = setInterval(& ...
- java 合并排序算法、冒泡排序算法、选择排序算法、插入排序算法、快速排序算法的描述
算法是在有限步骤内求解某一问题所使用的一组定义明确的规则.通俗点说,就是计算机解题的过程.在这个过程中,无论是形成解题思路还是编写程序,都是在实施某种算法.前者是推理实现的算法,后者是操作实现的算法. ...
- 云计算之路-试用Azure:搭建自己的内网DNS服务器
之前我们写过一篇博文谈到Azure内置的内网DNS服务器不能跨Cloud Service,而我们的虚拟机部署场景恰恰需要跨多个Cloud Service,所以目前只能选择用Azure虚拟机搭建自己的内 ...
- 虚拟机集群出现“Device eth0 does not seem to be present, delaying initialization” failed
问题再现: 解决办法: 1:编辑/etc/sysconfig/network-scripts/ifcfg-eth0配置文件,将ifcfg-eth0的配置文件里里面以前的关于MAC地址这一行删除掉.另外 ...
- ASUS主板ALC887声卡,RTL81XX网卡,黑苹果驱动安装
折腾了一下午终于在黑苹果上成功的安装了网卡,声卡驱动: 我的配置: 主板 ASUS b75m-a 声卡 ALC887 网卡 RTL8168F 安装所需工具: MutiBest 下载OS对应的版本即可 ...
- 【转】maven常见问题问答
转自:http://www.iteye.com/topic/973166 前言 Maven,发音是[`meivin],"专家"的意思.它是一个很好的项目管理工具,很早就进入了我的必 ...
- struts2+jquery验证注冊用户是否存在
注冊界面 register.jsp <%@ page language="java" contentType="text/html; charset=UTF-8&q ...
- 03-spring学习-自动装配
自动装配 新建person类: package com.spring.bean.autowire; public class Person { private String name; private ...