当前位置: 首页 > news >正文

WARNING: Access control is not enabled for the database.

MongoDB shell version v3.4.24

WARNING: Access control is not enabled for the database.
Read and write access to data and configuration is unrestricted.
1)未启用访问控制
2)读写访问不受限制

D:\MongoDB\Server\3.4\bin>mongo
MongoDB shell version v3.4.24
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.24
Welcome to the MongoDB shell.
For interactive help, type "help".
For more comprehensive documentation, seehttp://docs.mongodb.org/
Questions? Try the support grouphttp://groups.google.com/group/mongodb-user
Server has startup warnings:
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten]
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten]
>
> db
test
>
>

MongoDB: Server has startup warnings ''Access control is not enabled for the database'' - Stack Overflow

Mongodb v3.4
You need to do the following to create a secure database:
Make sure the user starting the process has permissions and that the directories exist (/data/db in this case).
1) Start MongoDB without access control.
mongod --port 27017 --dbpath /data/db
2) Connect to the instance.
mongo --port 27017
3) Create the user administrator (in the admin authentication database).
use admin
db.createUser({user: "myUserAdmin",pwd: "abc123",roles: [ { role: "userAdminAnyDatabase", db: "admin" } ]}
)
4) Re-start the MongoDB instance with access control.
mongod --auth --port 27017 --dbpath /data/db
5) Connect and authenticate as the user administrator.
mongo --port 27017 -u "myUserAdmin" -p "abc123" --authenticationDatabase "admin"
6) Create additional users as needed for your deployment (e.g. in the test authentication database).
use test
db.createUser({user: "myTester",pwd: "xyz123",roles: [ { role: "readWrite", db: "test" },{ role: "read", db: "reporting" } ]}
)
7) Connect and authenticate as myTester.
mongo --port 27017 -u "myTester" -p "xyz123" --authenticationDatabase "test"
I basically just explained the short version of the official docs here: https://docs.mongodb.com/master/tutorial/enable-authentication/

==

1)

D:\MongoDB\Server\3.4\bin>mongo
MongoDB shell version v3.4.24
connecting to: mongodb://127.0.0.1:27017
MongoDB server version: 3.4.24
Server has startup warnings:
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten]
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten] ** WARNING: Access control is not enabled for the database.
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten] **          Read and write access to data and configuration is unrestricted.
2023-11-29T16:56:25.314+0800 I CONTROL  [initandlisten]
>
>
> use admin
switched to db admin
>
> db.createUser({user:"admin",pwd:"123456",roles:[{role:"userAdminAnyDatabase", db:"admin"}]})
Successfully added user: {"user" : "admin","roles" : [{"role" : "userAdminAnyDatabase","db" : "admin"}]
}
>
>

2)

mongod --auth --port 27017 --dbpath D:\MongoDB\Server\3.4\data\db

【. Is a mongod instance already running?, terminating】

D:\MongoDB\Server\3.4\bin>
D:\MongoDB\Server\3.4\bin>
D:\MongoDB\Server\3.4\bin>mongod --auth --port 27017 --dbpath D:\MongoDB\Server\3.4\data\db
2023-11-30T06:07:07.775+0800 I CONTROL  [initandlisten] MongoDB starting : pid=38192 port=27017 dbpath=D:\MongoDB\Server\3.4\data\db 64-bit host=thinkpad-t440p-zwf
2023-11-30T06:07:07.779+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2023-11-30T06:07:07.780+0800 I CONTROL  [initandlisten] db version v3.4.24
2023-11-30T06:07:07.780+0800 I CONTROL  [initandlisten] git version: 865b4f6a96d0f5425e39a18337105f33e8db504d
2023-11-30T06:07:07.783+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2023-11-30T06:07:07.783+0800 I CONTROL  [initandlisten] modules: none
2023-11-30T06:07:07.784+0800 I CONTROL  [initandlisten] build environment:
2023-11-30T06:07:07.784+0800 I CONTROL  [initandlisten]     distmod: 2008plus
2023-11-30T06:07:07.785+0800 I CONTROL  [initandlisten]     distarch: x86_64
2023-11-30T06:07:07.785+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2023-11-30T06:07:07.786+0800 I CONTROL  [initandlisten] options: { net: { port: 27017 }, security: { authorization: "enabled" }, storage: { dbPath: "D:\MongoDB\Server\3.4\data\db" } }
2023-11-30T06:07:07.788+0800 I STORAGE  [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: D:\MongoDB\Server\3.4\data\db\mongod.lock 另一个程序正在使用此文件,进程无法访问。. Is a mongod instance already running?, terminating
2023-11-30T06:07:07.788+0800 I NETWORK  [initandlisten] shutdown: going to close listening sockets...
2023-11-30T06:07:07.788+0800 I NETWORK  [initandlisten] shutdown: going to flush diaglog...
2023-11-30T06:07:07.789+0800 I CONTROL  [initandlisten] now exiting
2023-11-30T06:07:07.789+0800 I CONTROL  [initandlisten] shutting down with code:100D:\MongoDB\Server\3.4\bin>

3)任务管理器结束掉

4)

mongod --auth --port 27017 --dbpath D:\MongoDB\Server\3.4\data\db


Successfully authenticated as principal admin on admin from client 127.0.0.1:52564
Unauthorized: not authorized on admin to execute command { getLog: "startupWarnings" }
Unauthorized: not authorized on admin to execute command { getCmdLineOpts: 1.0 }
Unauthorized: not authorized on admin to execute command { replSetGetStatus: 1.0, forShell: 1.0 }

Unauthorized: not authorized on admin to execute command-CSDN博客

D:\MongoDB\Server\3.4\bin>mongod --auth --port 27017 --dbpath D:\MongoDB\Server\3.4\data\db
2023-11-30T06:15:18.468+0800 I CONTROL  [initandlisten] MongoDB starting : pid=9644 port=27017 dbpath=D:\MongoDB\Server\3.4\data\db 64-bit host=thinkpad-t440p-zwf
2023-11-30T06:15:18.472+0800 I CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2023-11-30T06:15:18.472+0800 I CONTROL  [initandlisten] db version v3.4.24
2023-11-30T06:15:18.472+0800 I CONTROL  [initandlisten] git version: 865b4f6a96d0f5425e39a18337105f33e8db504d
2023-11-30T06:15:18.472+0800 I CONTROL  [initandlisten] allocator: tcmalloc
2023-11-30T06:15:18.473+0800 I CONTROL  [initandlisten] modules: none
2023-11-30T06:15:18.473+0800 I CONTROL  [initandlisten] build environment:
2023-11-30T06:15:18.473+0800 I CONTROL  [initandlisten]     distmod: 2008plus
2023-11-30T06:15:18.473+0800 I CONTROL  [initandlisten]     distarch: x86_64
2023-11-30T06:15:18.473+0800 I CONTROL  [initandlisten]     target_arch: x86_64
2023-11-30T06:15:18.473+0800 I CONTROL  [initandlisten] options: { net: { port: 27017 }, security: { authorization: "enabled" }, storage: { dbPath: "D:\MongoDB\Server\3.4\data\db" } }
2023-11-30T06:15:18.475+0800 I -        [initandlisten] Detected data files in D:\MongoDB\Server\3.4\data\db created by the 'wiredTiger' storage engine, so setting the active storage engine to 'wiredTiger'.
2023-11-30T06:15:18.476+0800 I STORAGE  [initandlisten] wiredtiger_open config: create,cache_size=7523M,session_max=20000,eviction=(threads_min=4,threads_max=4),config_base=false,statistics=(fast),log=(enabled=true,archive=true,path=journal,compressor=snappy),file_manager=(close_idle_time=100000),checkpoint=(wait=60,log_size=2GB),statistics_log=(wait=0),verbose=(recovery_progress),
2023-11-30T06:15:18.781+0800 I STORAGE  [initandlisten] WiredTiger message [1701296118:781568][9644:140709756164912], txn-recover: Main recovery loop: starting at 2/5504
2023-11-30T06:15:18.946+0800 I STORAGE  [initandlisten] WiredTiger message [1701296118:945168][9644:140709756164912], txn-recover: Recovering log 2 through 3
2023-11-30T06:15:19.068+0800 I STORAGE  [initandlisten] WiredTiger message [1701296119:67846][9644:140709756164912], txn-recover: Recovering log 3 through 3
2023-11-30T06:15:20.419+0800 I FTDC     [initandlisten] Initializing full-time diagnostic data capture with directory 'D:/MongoDB/Server/3.4/data/db/diagnostic.data'
2023-11-30T06:15:20.427+0800 I NETWORK  [thread1] waiting for connections on port 27017
2023-11-30T06:15:25.062+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:52506 #1 (1 connection now open)
2023-11-30T06:15:25.065+0800 I NETWORK  [conn1] received client metadata from 127.0.0.1:52506 conn1: { driver: { name: "mongo-java-driver|sync|spring-boot", version: "4.6.1" }, os: { type: "Windows", name: "Windows 10", architecture: "amd64", version: "10.0" }, platform: "Java/Oracle Corporation/1.8.0_341-b10" }
2023-11-30T06:15:26.157+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:52510 #2 (2 connections now open)
2023-11-30T06:15:26.162+0800 I NETWORK  [conn2] received client metadata from 127.0.0.1:52510 conn2: { driver: { name: "mongo-java-driver|sync|spring-boot", version: "4.6.1" }, os: { type: "Windows", name: "Windows 10", architecture: "amd64", version: "10.0" }, platform: "Java/Oracle Corporation/1.8.0_341-b10" }
2023-11-30T06:16:48.976+0800 I NETWORK  [thread1] connection accepted from 127.0.0.1:52564 #3 (3 connections now open)
2023-11-30T06:16:48.977+0800 I NETWORK  [conn3] received client metadata from 127.0.0.1:52564 conn3: { application: { name: "MongoDB Shell" }, driver: { name: "MongoDB Internal Client", version: "3.4.24" }, os: { type: "Windows", name: "Microsoft Windows 8", architecture: "x86_64", version: "6.2 (build 9200)" } }
2023-11-30T06:16:48.999+0800 I ACCESS   [conn3] Successfully authenticated as principal admin on admin from client 127.0.0.1:52564
2023-11-30T06:16:49.022+0800 I ACCESS   [conn3] Unauthorized: not authorized on admin to execute command { getLog: "startupWarnings" }
2023-11-30T06:16:49.038+0800 I ACCESS   [conn3] Unauthorized: not authorized on admin to execute command { getCmdLineOpts: 1.0 }
2023-11-30T06:16:49.040+0800 I ACCESS   [conn3] Unauthorized: not authorized on admin to execute command { replSetGetStatus: 1.0, forShell: 1.0 }

5)mongo --port 27017 -u "admin" -p "123456" --authenticationDatabase "admin"

Microsoft Windows [版本 10.0.19045.2965]
(c) Microsoft Corporation。保留所有权利。C:\Users\Administrator>d:D:\>
D:\>cd D:\MongoDB\Server\3.4\binD:\MongoDB\Server\3.4\bin>
D:\MongoDB\Server\3.4\bin>
D:\MongoDB\Server\3.4\bin>mongo --port 27017 -u "admin" -p "123456" --authenticationDatabase "admin"
MongoDB shell version v3.4.24
connecting to: mongodb://127.0.0.1:27017/
MongoDB server version: 3.4.24

相关文章:

WARNING: Access control is not enabled for the database.

MongoDB shell version v3.4.24 WARNING: Access control is not enabled for the database. Read and write access to data and configuration is unrestricted. 1)未启用访问控制 2)读写访问不受限制 D:\MongoDB\Server\3.4\bin>mongo MongoDB shell version v3.4.24 c…...

JavaScript编程进阶 – Return语句

JavaScript编程进阶 – Return语句 JavaScript Programming Advanced – Return Statement By JacksonML 就像人们习惯的函数一样,总觉得在函数体最后需要一个return语句,标志着函数的结束,就像下面这个函数 theFunc() 那样。 function theFunc() { re…...

Python与设计模式--备忘录模式

23种计模式之 前言 (5)单例模式、工厂模式、简单工厂模式、抽象工厂模式、建造者模式、原型模式、(7)代理模式、装饰器模式、适配器模式、门面模式、组合模式、享元模式、桥梁模式、(11)策略模式、责任链模式、命令模式、中介者模…...

04_Flutter自定义Slider滑块

04_Flutter自定义Slider滑块 一.Slider控件基本用法 Column(mainAxisAlignment: MainAxisAlignment.start,children: <Widget>[Text("sliderValue: ${_sliderValue.toInt()}"),Slider(value: _sliderValue,min: 0,max: 100,divisions: 10,thumbColor: Colors.…...

服务器数据恢复—EMC存储raid5故障导致上层应用崩溃的数据恢复案例

服务器存储数据恢复环境&#xff1a; EMC某型号存储&#xff0c;8块组建一组raid5磁盘阵列。上层操作系统采用zfs文件系统。 服务器存储故障&分析&#xff1a; raid5阵列中有2块硬盘未知原因离线&#xff0c;raid5阵列崩溃&#xff0c;上层应用无法正常使用。 服务器数据恢…...

7.1 Windows驱动开发:内核监控进程与线程回调

在前面的文章中LyShark一直在重复的实现对系统底层模块的枚举&#xff0c;今天我们将展开一个新的话题&#xff0c;内核监控&#xff0c;我们以监控进程线程创建为例&#xff0c;在Win10系统中监控进程与线程可以使用微软提供给我们的两个新函数来实现&#xff0c;此类函数的原…...

基于ssm的汽车论坛管理系统设计与实现

基于ssm的汽车论坛管理系统设计与实现 摘要&#xff1a;信息化社会内需要与之针对性的信息获取途径&#xff0c;但是途径的扩展基本上为人们所努力的方向&#xff0c;由于站在的角度存在偏差&#xff0c;人们经常能够获得不同类型信息&#xff0c;这也是技术最为难以攻克的课题…...

实习开发日志经验总结(一)

文章目录 前言实习日志经验总结 前言 自己之前实习过程中遇到的问题以及相应的解决过程&#xff0c;我都有记录形成比较凌乱的实习日志。故想在整个实习日志的基础上&#xff0c;提炼一些技术知识点或者是解决问题的思路。考虑到实习项目的不方便公开性&#xff0c;所以会隐去…...

【Unity基础】8.简单场景的搭建

【Unity基础】8.简单场景的搭建 大家好&#xff0c;我是Lampard~~ 欢迎来到Unity基础系列博客&#xff0c;所学知识来自B站阿发老师~感谢 &#xff08;一&#xff09;场景资源 &#xff08;1&#xff09;Import资源包 今天我们将手动去搭一个简单的场景&#xff0c;当…...

傅里叶变换及其在机器学习中的应用

​​​​​​​一、介绍 傅立叶变换是一种数学技术&#xff0c;在各个科学和工程领域发挥着关键作用&#xff0c;其应用范围从信号处理到量子力学。近年来&#xff0c;它在机器学习领域发现了新的意义。本文探讨了傅里叶变换的基础知识及其在机器学习应用中日益增长的重要性。 …...

xorm源码学习

文章目录 XORM源码浅析及实践ORMORM vs. SQLXORM软件架构 ORM 引擎 Engine——DBM*core.DB Golang&#xff1a;database/sql 源码基本结构连接复用&#xff0c;提高性能。增加数据库连接池数量连接管理 database/sql主要内容&#xff1a;sql.DB创建数据库连接sql.Open()DB.conn…...

Vue3中的<script setup>和<script>的区别

相同点 在一个 Vue3 单文件组件 (SFC)中&#xff0c;<script setup> 和 <script> 它们各自最多只能存在一个。 不同点 <script setup> 这个脚本块将被预处理为组件的 setup() 函数&#xff0c;这意味着它将为每一个(也可以说每一次)组件实例都执行。 <…...

Docker笔记-Docker搭建最新版zabbix服务端(2023-07-31)

前言 一开始问chartgpt上&#xff0c;搭建的思路是对的&#xff0c;但命令和细节有问题&#xff0c;最后还是依靠StackOverflow解决的。一开始在amd的linux上搭建好docker版的zabbix&#xff0c;但放到arm的机器上就报错了&#xff0c;原因是指令集不匹配&#xff0c;最后跑到…...

QT配合CSS隐藏按钮

第一种方法 在Qt的CSS样式表中&#xff0c;使用 visibility 属性来隐藏按钮。设置 visibility 为 hidden 不可见&#xff0c;而设置为 visible 则可见。 隐藏所有 QPushButton QPushButton {visibility: hidden; }隐藏特定的按钮&#xff0c;用按钮的名称或样式类进行定位就…...

2023亚太地区数学建模C题思路分析+模型+代码+论文

目录 1.2023亚太地区各题思路模型&#xff1a;比赛开始后&#xff0c;第一时间更新&#xff0c;获取见文末名片 3 常见数模问题常见模型分类 3.1 分类问题 3.2 优化问题 详细思路见此名片&#xff0c;开赛第一时间更新 1.亚太地区数学建模ABC题思路模型&#xff1a;9比赛开…...

Linguistic Steganalysis in Few-Shot Scenario论文阅读笔记

TIFS期刊 A类期刊 新知识点 Introduction Linguistic Steganalysis in Few-Shot Scenario模型是个预训练方法。 评估了四种文本加密分析方法&#xff0c;TS-CSW、TS-RNN、Zou、SeSy&#xff0c;用于分析和训练的样本都由VAE-Stego生产(编码方式使用AC编码)。 实验是对比在少样…...

详细学习Pyqt5的4种项目部件(Item Widget)

Pyqt5相关文章: 快速掌握Pyqt5的三种主窗口 快速掌握Pyqt5的2种弹簧 快速掌握Pyqt5的5种布局 快速弄懂Pyqt5的5种项目视图&#xff08;Item View&#xff09; 快速弄懂Pyqt5的4种项目部件&#xff08;Item Widget&#xff09; 快速掌握Pyqt5的6种按钮 快速掌握Pyqt5的10种容器&…...

notepad++ 插件JSONView安装

1&#xff0c;前提 开发过程中经常需要处理json格式语句&#xff0c;需要对json数据格式化处理&#xff0c;因为使用的是虚拟机内开发&#xff0c;所以没法连接外网&#xff0c;只能在本地电脑下载插件后&#xff0c;然后上传到虚拟机中&#xff0c;进行安装使用。 2&#xf…...

AKConv:具有任意采样形状和任意数目参数的卷积核

文章目录 摘要1、引言2、相关工作3、方法3.1、定义初始采样位置3.2、可变卷积操作3.3、扩展AKConv3.3、扩展AKConv 4、实验4.1、在COCO2017上的目标检测实验4.2、在VOC 712上的目标检测实验4.3、在VisDrone-DET2021上的目标检测实验4.4、比较实验4.5、探索初始采样形状 5、分析…...

如何使用C++开发集群服务

开发集群服务需要掌握以下技术&#xff1a; 分布式系统原理&#xff1a;了解集群的概念、工作原理、负载均衡、容错等相关概念。 网络编程&#xff1a;掌握Socket编程和HTTP协议等。 C编程&#xff1a;熟练掌握C语言的基础知识和STL等常用库。 多线程编程&#xff1a;了解线…...

Vue记事本应用实现教程

文章目录 1. 项目介绍2. 开发环境准备3. 设计应用界面4. 创建Vue实例和数据模型5. 实现记事本功能5.1 添加新记事项5.2 删除记事项5.3 清空所有记事 6. 添加样式7. 功能扩展&#xff1a;显示创建时间8. 功能扩展&#xff1a;记事项搜索9. 完整代码10. Vue知识点解析10.1 数据绑…...

让AI看见世界:MCP协议与服务器的工作原理

让AI看见世界&#xff1a;MCP协议与服务器的工作原理 MCP&#xff08;Model Context Protocol&#xff09;是一种创新的通信协议&#xff0c;旨在让大型语言模型能够安全、高效地与外部资源进行交互。在AI技术快速发展的今天&#xff0c;MCP正成为连接AI与现实世界的重要桥梁。…...

【碎碎念】宝可梦 Mesh GO : 基于MESH网络的口袋妖怪 宝可梦GO游戏自组网系统

目录 游戏说明《宝可梦 Mesh GO》 —— 局域宝可梦探索Pokmon GO 类游戏核心理念应用场景Mesh 特性 宝可梦玩法融合设计游戏构想要素1. 地图探索&#xff08;基于物理空间 广播范围&#xff09;2. 野生宝可梦生成与广播3. 对战系统4. 道具与通信5. 延伸玩法 安全性设计 技术选…...

GC1808高性能24位立体声音频ADC芯片解析

1. 芯片概述 GC1808是一款24位立体声音频模数转换器&#xff08;ADC&#xff09;&#xff0c;支持8kHz~96kHz采样率&#xff0c;集成Δ-Σ调制器、数字抗混叠滤波器和高通滤波器&#xff0c;适用于高保真音频采集场景。 2. 核心特性 高精度&#xff1a;24位分辨率&#xff0c…...

【VLNs篇】07:NavRL—在动态环境中学习安全飞行

项目内容论文标题NavRL: 在动态环境中学习安全飞行 (NavRL: Learning Safe Flight in Dynamic Environments)核心问题解决无人机在包含静态和动态障碍物的复杂环境中进行安全、高效自主导航的挑战&#xff0c;克服传统方法和现有强化学习方法的局限性。核心算法基于近端策略优化…...

Java求职者面试指南:计算机基础与源码原理深度解析

Java求职者面试指南&#xff1a;计算机基础与源码原理深度解析 第一轮提问&#xff1a;基础概念问题 1. 请解释什么是进程和线程的区别&#xff1f; 面试官&#xff1a;进程是程序的一次执行过程&#xff0c;是系统进行资源分配和调度的基本单位&#xff1b;而线程是进程中的…...

STM32HAL库USART源代码解析及应用

STM32HAL库USART源代码解析 前言STM32CubeIDE配置串口USART和UART的选择使用模式参数设置GPIO配置DMA配置中断配置硬件流控制使能生成代码解析和使用方法串口初始化__UART_HandleTypeDef结构体浅析HAL库代码实际使用方法使用轮询方式发送使用轮询方式接收使用中断方式发送使用中…...

BLEU评分:机器翻译质量评估的黄金标准

BLEU评分&#xff1a;机器翻译质量评估的黄金标准 1. 引言 在自然语言处理(NLP)领域&#xff0c;衡量一个机器翻译模型的性能至关重要。BLEU (Bilingual Evaluation Understudy) 作为一种自动化评估指标&#xff0c;自2002年由IBM的Kishore Papineni等人提出以来&#xff0c;…...

HubSpot推出与ChatGPT的深度集成引发兴奋与担忧

上周三&#xff0c;HubSpot宣布已构建与ChatGPT的深度集成&#xff0c;这一消息在HubSpot用户和营销技术观察者中引发了极大的兴奋&#xff0c;但同时也存在一些关于数据安全的担忧。 许多网络声音声称&#xff0c;这对SaaS应用程序和人工智能而言是一场范式转变。 但向任何技…...

tauri项目,如何在rust端读取电脑环境变量

如果想在前端通过调用来获取环境变量的值&#xff0c;可以通过标准的依赖&#xff1a; std::env::var(name).ok() 想在前端通过调用来获取&#xff0c;可以写一个command函数&#xff1a; #[tauri::command] pub fn get_env_var(name: String) -> Result<String, Stri…...