Windows中的MongoDB身份验证

Windows中的MongoDB身份验证,mongodb,admin,mongodb-authentication,Mongodb,Admin,Mongodb Authentication,我在本地主机中使用mongoDB已有一段时间了。我从一开始就没有对自己进行身份验证,也就是说,我没有用户名和密码。我直接在控制台中进行工作 现在我正在尝试suthenticate,我有一些问题: 首先,我这样做: use Admin db.createUser( { user: "superuser", pwd: "changeMeToAStrongPassword", roles: [ "root" ]

我在本地主机中使用mongoDB已有一段时间了。我从一开始就没有对自己进行身份验证,也就是说,我没有用户名和密码。我直接在控制台中进行工作

现在我正在尝试suthenticate,我有一些问题:

首先,我这样做:

use Admin

db.createUser(
  {
    user: "superuser",
    pwd: "changeMeToAStrongPassword",
    roles: [ "root" ]
  }
)
这没有显示任何错误,而且也显示了
用户
,并得到了我需要的结果

然后,按照MongoDB官方网站上的指示,我在命令提示符下完成了以下操作:

"C:\Program Files\MongoDB\Server\4.4\bin\mongod.exe" --dbpath "d:\test\mongo db data" --auth
我明白了:

{"t":{"$date":"2020-09-22T09:45:31.719+05:30"},"s":"I",  "c":"CONTROL",  "id":23285,   "ctx":"main","msg":"Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'"}
{"t":{"$date":"2020-09-22T09:45:31.729+05:30"},"s":"W",  "c":"ASIO",     "id":22601,   "ctx":"main","msg":"No TransportLayer configured during NetworkInterface startup"}
{"t":{"$date":"2020-09-22T09:45:31.731+05:30"},"s":"I",  "c":"NETWORK",  "id":4648602, "ctx":"main","msg":"Implicit TCP FastOpen in use."}
{"t":{"$date":"2020-09-22T09:45:31.747+05:30"},"s":"I",  "c":"STORAGE",  "id":4615611, "ctx":"initandlisten","msg":"MongoDB starting","attr":{"pid":6616,"port":27017,"dbPath":"d:/test/mongo db data","architecture":"64-bit","host":"LAPTOP-FRA3EPR8"}}
{"t":{"$date":"2020-09-22T09:45:31.748+05:30"},"s":"I",  "c":"CONTROL",  "id":23398,   "ctx":"initandlisten","msg":"Target operating system minimum version","attr":{"targetMinOS":"Windows 7/Windows Server 2008 R2"}}
{"t":{"$date":"2020-09-22T09:45:31.756+05:30"},"s":"I",  "c":"CONTROL",  "id":23403,   "ctx":"initandlisten","msg":"Build Info","attr":{"buildInfo":{"version":"4.4.1","gitVersion":"ad91a93a5a31e175f5cbf8c69561e788bbc55ce1","modules":[],"allocator":"tcmalloc","environment":{"distmod":"windows","distarch":"x86_64","target_arch":"x86_64"}}}}
{"t":{"$date":"2020-09-22T09:45:31.762+05:30"},"s":"I",  "c":"CONTROL",  "id":51765,   "ctx":"initandlisten","msg":"Operating System","attr":{"os":{"name":"Microsoft Windows 10","version":"10.0 (build 18362)"}}}
{"t":{"$date":"2020-09-22T09:45:31.774+05:30"},"s":"I",  "c":"CONTROL",  "id":21951,   "ctx":"initandlisten","msg":"Options set by command line","attr":{"options":{"security":{"authorization":"enabled"},"storage":{"dbPath":"d:\\test\\mongo db data"}}}}
{"t":{"$date":"2020-09-22T09:45:31.798+05:30"},"s":"E",  "c":"STORAGE",  "id":20557,   "ctx":"initandlisten","msg":"DBException in initAndListen, terminating","attr":{"error":"NonExistentPath: Data directory d:\\test\\mongo db data not found. Create the missing directory or specify another path using (1) the --dbpath command line option, or (2) by adding the 'storage.dbPath' option in the configuration file."}}
{"t":{"$date":"2020-09-22T09:45:31.799+05:30"},"s":"I",  "c":"REPL",     "id":4784900, "ctx":"initandlisten","msg":"Stepping down the ReplicationCoordinator for shutdown","attr":{"waitTimeMillis":10000}}
{"t":{"$date":"2020-09-22T09:45:31.806+05:30"},"s":"I",  "c":"COMMAND",  "id":4784901, "ctx":"initandlisten","msg":"Shutting down the MirrorMaestro"}
{"t":{"$date":"2020-09-22T09:45:31.812+05:30"},"s":"I",  "c":"SHARDING", "id":4784902, "ctx":"initandlisten","msg":"Shutting down the WaitForMajorityService"}
{"t":{"$date":"2020-09-22T09:45:31.824+05:30"},"s":"I",  "c":"NETWORK",  "id":20562,   "ctx":"initandlisten","msg":"Shutdown: going to close listening sockets"}
{"t":{"$date":"2020-09-22T09:45:31.829+05:30"},"s":"I",  "c":"NETWORK",  "id":4784905, "ctx":"initandlisten","msg":"Shutting down the global connection pool"}
{"t":{"$date":"2020-09-22T09:45:31.839+05:30"},"s":"I",  "c":"STORAGE",  "id":4784906, "ctx":"initandlisten","msg":"Shutting down the FlowControlTicketholder"}
{"t":{"$date":"2020-09-22T09:45:31.847+05:30"},"s":"I",  "c":"-",        "id":20520,   "ctx":"initandlisten","msg":"Stopping further Flow Control ticket acquisitions."}
{"t":{"$date":"2020-09-22T09:45:31.858+05:30"},"s":"I",  "c":"NETWORK",  "id":4784918, "ctx":"initandlisten","msg":"Shutting down the ReplicaSetMonitor"}
{"t":{"$date":"2020-09-22T09:45:31.873+05:30"},"s":"I",  "c":"SHARDING", "id":4784921, "ctx":"initandlisten","msg":"Shutting down the MigrationUtilExecutor"}
{"t":{"$date":"2020-09-22T09:45:31.880+05:30"},"s":"I",  "c":"CONTROL",  "id":4784925, "ctx":"initandlisten","msg":"Shutting down free monitoring"}
{"t":{"$date":"2020-09-22T09:45:31.891+05:30"},"s":"I",  "c":"FTDC",     "id":4784926, "ctx":"initandlisten","msg":"Shutting down full-time data capture"}
{"t":{"$date":"2020-09-22T09:45:31.896+05:30"},"s":"I",  "c":"STORAGE",  "id":4784927, "ctx":"initandlisten","msg":"Shutting down the HealthLog"}
{"t":{"$date":"2020-09-22T09:45:31.906+05:30"},"s":"I",  "c":"STORAGE",  "id":4784929, "ctx":"initandlisten","msg":"Acquiring the global lock for shutdown"}
{"t":{"$date":"2020-09-22T09:45:31.912+05:30"},"s":"I",  "c":"-",        "id":4784931, "ctx":"initandlisten","msg":"Dropping the scope cache for shutdown"}
{"t":{"$date":"2020-09-22T09:45:31.923+05:30"},"s":"I",  "c":"CONTROL",  "id":20565,   "ctx":"initandlisten","msg":"Now exiting"}
{"t":{"$date":"2020-09-22T09:45:31.929+05:30"},"s":"I",  "c":"CONTROL",  "id":23138,   "ctx":"initandlisten","msg":"Shutting down","attr":{"exitCode":100}}
我甚至尝试过创建目录,但似乎不起作用。
请帮助

错误非常清楚:
错误:“
不存在路径:数据目录d:\\test\\mongo数据库未找到”。创建缺少的目录或使用(1)--dbpath命令行选项指定另一个路径,或(2)在配置文件中添加“storage.dbpath”选项。“
文件夹是否存在?您是否对其具有写入权限?可以尝试不带空格字符的文件夹。