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适用于使用基于『用户名:密码』这 ...
随机推荐
- SQL-ORDER BY 多字段排序(升序、降序)
ORDER BY _column1, _column2; /* _column1升序,_column2升序 */ ORDER BY _column1, _column2 DESC; /* _col ...
- mac下在eclipse中怎样清除/切换svn
1.打开终端,即用户的根文件夹(用户的home文件夹) 进入.subversion下的auth文件夹 localhost:auth brj$ pwd /Users/brj/.subversion/au ...
- JDBC数据库编程:ResultSet接口
掌握ResultSet接口 使用ResultSet接口进行查询 ResultSet接口 在JDBC操作中,数据库所有查询记录将使用ResultSet进行接收,并使用ResultSet显示内容. 常用方 ...
- hibernate 启动和辅助类实现资源的重复使用
来自API: 1.2.5. 启动和辅助类 是时候来加载和储存一些Event对象了,但首先我们得编写一些基础的代码以完成设置.我们必须启动Hibernate,此过程包括创建一个全局的SessoinFa ...
- 使用scrapy进行12306车票查询
概述 通过12306的查询API进行查询某日火车票, 结果保存在csv文件中. 详细 代码下载:http://www.demodashi.com/demo/12623.html 一.环境搭建 1. 安 ...
- WPF SL 属性生成器
在开发WPF 和SL应用的时候通用会用到MVVM模式,每次写到类属性的时候要不断的写属性更新时通知方法,写多了就嫌烦,就手写了个属性生成工具,在属性更新的时候添加了更新通知方法. 工具中支持自定义类对 ...
- 浅谈ThreadPool 线程池(引用)
出自:http://www.cnblogs.com/xugang/archive/2010/04/20/1716042.html 浅谈ThreadPool 线程池 相关概念: 线程池可以看做容纳线程的 ...
- Android新手入门2016(10)--GridView
本文来自肥宝传说之路.引用必须注明出处! GridView跟ListView一样是多控件布局.实现九宫图是最方便的. 还是先看看图,没图说个鸡鸡是不是 如上图.是一种应用方式.在每一个格子里面.放入应 ...
- Samba Server possible problem and solving
Configured samba server at RHEL7, problem encountered and solved. 1, yum install samba*, RHEL7 syste ...
- Xgboost 模型保存和载入()
https://blog.csdn.net/u012884015/article/details/78653178 xgb_model.get_booster().save_model('xgb.mo ...