简体   繁体   English

无法更改 mongod 的 dbPath

[英]Cannot change dbPath for mongod

I am trying to set up MongoDB v4.2.2 on Windows 10.我正在尝试在 Windows 10 上设置 MongoDB v4.2.2。

Whenever I run mongod, I am unable to change the dbPath, no matter what I do.每当我运行 mongod 时,无论我做什么,我都无法更改 dbPath。 It keeps defaulting to F:/MongoDB , every single time.它每次都默认为F:/MongoDB

This is the logs from running any form of the mongod command:这是运行任何形式的mongod命令的日志:

2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten] MongoDB starting : pid=9860 port=27017 dbpath=F:/MongoDB 64-bit host=DESKTOP-5CA5F06
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten] targetMinOS: Windows 7/Windows Server 2008 R2
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten] db version v4.2.2
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten] git version: a0bbbff6ada159e19298d37946ac8dc4b497eadf
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten] allocator: tcmalloc
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten] modules: none
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten] build environment:
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten]     distmod: 2012plus
2019-12-29T22:40:28.438-0800 I  CONTROL  [initandlisten]     distarch: x86_64
2019-12-29T22:40:28.439-0800 I  CONTROL  [initandlisten]     target_arch: x86_64
2019-12-29T22:40:28.439-0800 I  CONTROL  [initandlisten] options: { storage: { dbPath: "F:/MongoDB" } }
2019-12-29T22:40:28.440-0800 I  STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory F:/2019-12-29T22:40:28.440-0800 I  NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-12-29T22:40:28.440-0800 I  -        [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-12-29T22:40:28.440-0800 I  CONTROL  [initandlisten] now exiting
2019-12-29T22:40:28.441-0800 I  CONTROL  [initandlisten] shutting down with code:100

I first tried running mongod -dbpath C:/mongo-data/testdb , and got the above result.我首先尝试运行mongod -dbpath C:/mongo-data/testdb ,并得到上述结果。

I then tried mongod -dbpath "C:/mongo-data/testdb , to the same result.然后我尝试mongod -dbpath "C:/mongo-data/testdb ,得到相同的结果。

Then I changedthe mongod.cfg file in C:/Program Files/MongoDB/Server/4.2/bin to be the following:然后我将C:/Program Files/MongoDB/Server/4.2/bin mongod.cfg文件更改为以下内容:

# mongod.conf

# for documentation of all options, see:
#   http://docs.mongodb.org/manual/reference/configuration-options/

# Where and how to store data.
storage:
  dbPath: "C:\mongo-data\testdb"
  journal:
    enabled: true
#  engine:
#  mmapv1:
#  wiredTiger:

# where to write logging data.
systemLog:
  destination: file
  logAppend: true
  path:  %MONGO_LOG_PATH%\mongod.log

# network interfaces
net:
  port: 27017
  bindIp: 127.0.0.1


#processManagement:

#security:

#operationProfiling:

#replication:

#sharding:

## Enterprise-Only Options:

#auditLog:

#snmp:

and then ran mongod , followed by the two commands above once more.然后运行mongod ,再次执行上面的两个命令。 Each time, I got the same exact result I posted above.每次,我都得到了与上面发布的完全相同的结果。

I also tried removing the quotes around the value for dbPath in the config, and running each command again to the same result.我还尝试删除配置中 dbPath 值周围的引号,并再次运行每个命令以获得相同的结果。

How on earth do I get mongod to stop looking for this F:/MongoDB directory that doesn't exist?我到底如何让 mongod 停止寻找这个不存在的F:/MongoDB目录?

Please give it a try with mongod --dbpath "C:/mongo-data/testdb" .请尝试使用mongod --dbpath "C:/mongo-data/testdb"

Change here is, the dbpath comes with '--' instead of a single one.这里的变化是,dbpath 带有“--”而不是单个。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM