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适用于使用基于『用户名:密码』这 ...
随机推荐
- Appium处理滑动方法是swipe
滑动API:Swipe(int start x,int start y,int end x,int y,duration) 解释: int start x-开始滑动的x坐标:int start y - ...
- 【转】iBatis简单入门教程
1. iBatis 简介: iBatis 是apache 的一个开源项目,一个O/R Mapping 解决方案,iBatis 最大的特点就是小巧,上手很快.如果不需要太多复杂的功能,iBatis 是能 ...
- 算法笔记_070:BellmanFord算法简单介绍(Java)
目录 1 问题描述 2 解决方案 2.1 具体编码 1 问题描述 何为BellmanFord算法? BellmanFord算法功能:给定一个加权连通图,选取一个顶点,称为起点,求取起点到其它所有顶 ...
- webDriver API——第11部分Remote WebDriver
The WebDriver implementation. class selenium.webdriver.remote.webdriver.WebDriver(command_executor=' ...
- Sublime Text 如何一个代码双屏显示代码上下部分?
Sublime Text 如何一个代码双屏显示代码上下部分? sublime text如何一个代码双屏显示代码上下部分 先显示2行实图 把想要分屏显示的文件,打开新窗口,然后再拖过去就可以了. 快捷操 ...
- 10-spring学习-注入Resource
注入Resource 虽然Resource 的子类利用了字符串格式进行了隐藏,但是此时的代码中,ResourceLoader跟我的开发没有任何关系, 如果真的开发只关心Resource一个接口就够了. ...
- JDBC数据库编程:ResultSet接口
掌握ResultSet接口 使用ResultSet接口进行查询 ResultSet接口 在JDBC操作中,数据库所有查询记录将使用ResultSet进行接收,并使用ResultSet显示内容. 常用方 ...
- 对正在运行的mysql进行监控
对正在运行的mysql进行监控,其中一个方式就是查看mysql运行状态. (1)QPS(每秒Query量) QPS = Questions(or Queries) / seconds mysql &g ...
- java集成jpush实现客户端推送
代码地址如下:http://www.demodashi.com/demo/13700.html 前言 java 集成jpush 实现客户端推送 一.准备工作 开发环境: jdk1.6 Eclipse ...
- 使用 WinEdt 来写中文文章or 建模论文
找了几乎两个小时…… 后来发现… WinEdt 是可以用来写中文文章的…而并非只能英文文章或演示文稿… \documentclass{article} \usepackage{CJK} \begin{ ...