【问题标题】:Set DB path for Mongodb via terminal通过终端设置 MongoDB 的 DB 路径
【发布时间】:2019-11-03 02:30:07
【问题描述】:

尝试初始化 mongod,但出现以下错误。我知道数据库路径设置不正确。 Mac如何设置数据库路径?

我要设置的路径是“/Users/kopal/Downloads/mongodb-macos-x86_64-4.2.1/bin/data”

2019-11-02T22:11:51.748-0400 I  CONTROL  [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols 'none'
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten] MongoDB starting : pid=2292 port=27017 dbpath=/data/db 64-bit host=Kopals-MacBook-Air.local
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten] db version v4.2.1
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten] git version: edf6d45851c0b9ee15548f0f847df141764a317e
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten] allocator: system
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten] modules: none
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten] build environment:
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten]     distarch: x86_64
2019-11-02T22:11:51.777-0400 I  CONTROL  [initandlisten]     target_arch: x86_64
2019-11-02T22:11:51.778-0400 I  CONTROL  [initandlisten] options: {}
2019-11-02T22:11:51.786-0400 I  STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2019-11-02T22:11:51.789-0400 I  NETWORK  [initandlisten] shutdown: going to close listening sockets...
2019-11-02T22:11:51.789-0400 I  NETWORK  [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2019-11-02T22:11:51.789-0400 I  -        [initandlisten] Stopping further Flow Control ticket acquisitions.
2019-11-02T22:11:51.790-0400 I  CONTROL  [initandlisten] now exiting
2019-11-02T22:11:51.790-0400 I  CONTROL  [initandlisten] shutting down with code:100```

【问题讨论】:

  • 这能回答你的问题吗? how to set mongod --dbpath
  • 不,我在 Stackoverflow 上尝试了很多东西。
  • 不!错误不一样。但我试过了,它在 Mac OS 中没有帮助
  • 那你的路径就错了。
  • 是的!这也是我在帖子中提到的。但我无法正确设置。

标签: mongodb macos mongoose path


【解决方案1】:

启动mongod时,添加--dbpath选项如:

mongod --dbpath "/Users/kopal/Downloads/mongodb-macos-x86_64-4.2.1/bin/data"

或者在mongod.conf中设置路径如下。

storage:
    dbPath: "/Users/kopal/Downloads/mongodb-macos-x86_64-4.2.1/bin/data"

【讨论】:

  • 在哪里可以找到这个文件 mongod.conf。我看不到。我是 DB 新手。
  • 请检查错误消息是否打印您使用选项 --dbpath 设置的路径。
猜你喜欢
  • 2013-10-06
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2021-05-30
  • 2014-08-23
  • 1970-01-01
  • 1970-01-01
  • 2017-01-15
相关资源
最近更新 更多