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 …

2023.11.27 滴滴P0级故障或为k8s升级造成

滴滴11.27 P0级故障|打车|宕机|网约车|出租车|滴滴出行|系统故障_网易订阅 (163.com) 如何看待滴滴11月27日故障,对日常生产生活有哪些影响? - 知乎 (zhihu.com) 最新消息滴滴P0故障原因,是由于k8s集群升级导致的,后面又进行版本…

每日OJ题_算法_滑动窗口①_力扣209. 长度最小的子数组

力扣209. 长度最小的子数组 209. 长度最小的子数组 - 力扣(LeetCode) 难度 中等 给定一个含有 n 个正整数的数组和一个正整数 target 。 找出该数组中满足其总和大于等于 target 的长度最小的 连续子数组 [numsl, numsl1, ..., numsr-1, numsr] &…

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

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

常用Java开发规范整理

常用Java开发规范整理 命名时 接口类中的方法和属性不要加任何修饰符号( public 也不要加),保持代码的简洁性,并加上有效的 javadoc 注释代码中相同意义的概念的单词可能有多种,在业务中应该统一禁止中英文混合使用 …

使用 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…

C++学不会?一篇文章带你快速入门

1. 命名空间 1.1 命名空间的概念 C命名空间是一种用于避免名称冲突的机制。它允许在多个文件中定义相同的函数、类或变量,而不会相互干扰。 1.2 命名空间的定义 namespace是命名空间的关键字,后面是命名空间的名字,然后后面一对 {},{}中即…

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

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

物联网技术发展

▶1、物联网的发展 2005年,国际电信联盟(ITU)发布了《ITU互联网报告2005:物联网》报告,正式提出了物联网(IOT)的概念。ITU报告指出:无所不在的“物联网”通信时代即将来临,世界上所有的物体(从轮胎到牙刷、从房屋到纸巾)都可以通…

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)二、效…

c++的文件读写

#include<iostream> #include<string> //1&#xff1a;引入头文件 #include<fstream> using namespace std; //把程序中的信息输出到缓冲区&#xff0c;然后写到文件 void test01() {//2:定义流对象ofstream ofs;//3:打开文件&#xff0c;以写的方式打开&…

ubuntu离线安装包

方便快捷方式 查看依赖 apt-cache depends 包名(gcc或language-pack-zh-hans)下载deb及其依赖包 # 下载.deb包到指定目录 cd /var/cache/apt/archives apt-get download $(apt-cache depends --recurse --no-recommends --no-suggests --no-conflicts --no-breaks --no-repl…

react中useState、useRef、变量之间的区别

函数组件有函数作用域&#xff0c;每次render时&#xff0c;声明的方法会生成新的引用&#xff0c;声明的普通变量会重新声明并赋值初始值&#xff0c;而useRef和useState会保留状态。 useState、useRef、变量的区别 1. useState 组件更新不会改变之前的状态&#xff0c;可以保…

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

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

全汉电源SN生产日期解读

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

JS代码其实可以这样写

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

MySQL之 InnoDB逻辑存储结构

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