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

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/186407.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

【Vulnhub 靶场】【DriftingBlues: 9 (final)】【简单】【20210509】

1、环境介绍 靶场介绍:https://www.vulnhub.com/entry/driftingblues-9-final,695/ 靶场下载:https://download.vulnhub.com/driftingblues/driftingblues9.ova 靶场难度:简单 发布日期:2021年05月09日 文件大小:738 …

【JavaEE】多线程 -- 死锁问题

目录 1. 问题引入 2.死锁问题的概念和原因 3. 解决死锁问题 1. 问题引入 在学习死锁之前, 我们先观察下面的代码能否输出正确的结果: 运行程序, 能正常输出结果: 这个代码只管上看起来, 好像是有锁冲突的, 此时的 locker 对象已经是加锁的状态, 在尝试对 locker 加锁, 不应该…

使用 OpenTelemetry 和 Golang

入门 在本文中,我将展示你需要配置和处理统计信息所需的基本代码。在这个简短的教程中,我们将使用 Opentelemetry 来集成我们的 Golang 代码,并且为了可视化,我们将使用 Jeager。 在开始之前,让我简要介绍一下什么是 …

go学习之json和单元测试知识

文章目录 一、json以及序列化1.概述2.json应用场景图3.json数据格式说明4.json的序列化1)介绍2)应用案例 5.json的反序列化1)介绍2)应用案例 二、单元测试1.引子2.单元测试-基本介绍3.代码实现4.单元测试的细节说明5.单元测试的综…

中国毫米波雷达产业分析4——毫米波雷达企业介绍

一、矽典微 (一)公司简介 矽典微致力于实现射频技术的智能化,专注于研发高性能无线技术相关芯片,产品广泛适用于毫米波传感器、下一代移动通信、卫星通信等无线领域。 整合自身在芯片、系统、软件、算法等领域的专业能力&#xf…

【论文速递】:老驾驶员轨迹数据中的异常行为检测

给定道路网络和一组轨迹数据,异常行为检测 (ABD) 问题是识别在行程中表现出明显方向偏差、急刹车和加速的驾驶员。ABD 问题在许多社会应用中都很重要,包括轻度认知障碍 (MCI) 检测和老年驾驶员的安全路线建…

Redis未授权访问-CNVD-2019-21763复现

Redis未授权访问-CNVD-2019-21763复现 利用项目: https://github.com/vulhub/redis-rogue-getshell 解压后先进入到 RedisModulesSDK目录里面的exp目录下,make编译一下才会产生exp.so文件,后面再利用这个exp.so文件进行远程代码执行 需要p…

Python基础语法之学习字符串格式化

Python基础语法之学习字符串格式化 一、代码二、效果 一、代码 # 通过m.n控制 a 123 b 123.444 c 123.555 print("限制为5:%5d" % a) print("限制为2:%2d" % a) print("限制为5.2:%5.2f" % b) print("限制为5.2:%5.2f" % c)二、效…

高效解决在本地打开可视化服务器端的tensorboard

文章目录 问题解决方案 问题 由于连着远程服务器构建模型,但是想在本地可视化却做不到,不要想当然天真的以为CTRLC点击链接http://localhost:6006就真能在本地打开tensorboard。你电脑都没连接服务器,只是pycharm连上了而已 解决方案 你需要…

全汉电源SN生产日期解读

新买了一个全汉的电脑电源,SN:WZ3191900030,看了几次没想明白,最后估计SN是2023年19周这样来记录日期的。问了一下京东全汉客服,果然就是这样的。那大家如果在闲鱼上看到全汉电源,就知道它的生产日期了。

JS代码其实可以这样写

日常工作中,我确实经常去帮大家review代码,长期以来,我发现有些个功能函数,JS其实可以稍微调整一下,或者换个方式来处理,代码就会看起来更清晰,更简洁,甚至效率更高,主要…

MySQL之 InnoDB逻辑存储结构

InnoDB逻辑存储结构 InnoDB将所有数据都存放在表空间中,表空间又由段(segment)、区(extent)、页(page)组成。InnoDB存储引擎的逻辑存储结构大致如下图。下面我们就一个个来看看。 页&#xff08…

智慧配电间(配电室智能监控)

智慧配电间是一种应用物联网、云计算、大数据等先进技术,对配电室进行智能化改造和升级,依托电易云-智慧电力物联网,实现电力设备的实时监控、智能控制和远程管理的解决方案。以下是智慧配电间的主要功能和特点: 实时监控与数据分…

中式言情短剧APP力压TikTok荣登美国下载榜一!外国人也难逃“霸总爱上我”的狗血剧?

开局退婚、豪门恩怨、霸道总裁爱上我……这些由中国团队拍摄、外国演员出演的竖屏霸总短剧,正在海外收割市场。 01 ReelShort力压TikTok冲上美国榜一 TKFFF获悉,国内数字出版企业中文在线旗下短剧App ReelShort日前力压TikTok冲上美国iOS娱乐榜第1名&…

[Matlab有限元分析] 2.杆单元有限元分析

1. 一维杆单元有限元分析程序 一维刚单元的局部坐标系(单元坐标系)与全局坐标系相同。 1.1 线性杆单元 如图所示是一个杆单元,由两个节点i和j,局部坐标系的X轴沿着杆的方向,由i节点指向j节点,每个节点有…

唯品会年度特卖大会㊙内购清单㊙

唯品会年度特卖大会㊙内购清单㊙ 内部员工亲友专享,实实在在省钱,❌抢完不补! 今晚8点开抢,提前收藏>> https://t.vip.com/Im3KlTnDSJ8 2023年唯品会年度特卖大会热门会场推荐 1.唯品会年度特卖大会 限时加码!瓜分百万津贴!抢海量…

【软件测试】白盒测试和黑盒测试

一、软件测试基本分类 一般地,我们将软件测试活动分为以下几类:黑盒测试、白盒测试、静态测试、动态测试、手动测试、自动测试等等。 黑盒测试 黑盒测试又叫功能测试、数据驱动测试或给予需求规格说明书的功能测试。这种测试注重于测试软件的功能性需…

什么是木马

木马 1. 定义2. 木马的特征3. 木马攻击流程4. 常见木马类型5. 如何防御木马 1. 定义 木马一名来源于古希腊特洛伊战争中著名的“木马计”,指可以非法控制计算机,或在他人计算机中从事秘密活动的恶意软件。 木马通过伪装成正常软件被下载到用户主机&…

【laBVIEW学习】4.声音播放,自定义图标,滚动条设置

一。声音播放(报错,未实现) 1.报错4810 2.解决方法: 暂时未解决。 二。图片修改 1.目标:灯泡---》自定义灯泡 2.步骤: 1.右键点击--》自定义运行 表示可以制作自定义类型 2.右键--》打开自定义类型 这样就…

Python streamlit指南,构建令人惊叹的可视化Web界面!

更多资料获取 📚 个人网站:ipengtao.com 在当今数据驱动的世界中,构建交互式、美观且高效的数据可视化应用变得至关重要。而Streamlit,作为Python生态系统中为开发者提供了轻松创建Web应用的利器。 本文将深入探讨Streamlit的方…