0

Trying to initialize mongod, but getting below error. I know DB path is not set correctly. How can I set DB path in Mac?

The path I'm trying to set is "/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```
Veronica
  • 181
  • 1
  • 11

1 Answers1

0

When you start mongod, add the --dbpath option such as:

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

or set the path in the mongod.conf as follows.

storage:
    dbPath: "/Users/kopal/Downloads/mongodb-macos-x86_64-4.2.1/bin/data"
Lamanus
  • 12,898
  • 4
  • 21
  • 47