Change default DB Path

When i start this exercise i get the first instruction to create a new folder /var/mongodb/db/ by using mkdir -p /var/mongodb/db
So I start the mongod and run this command and nothing executes. I try to config it first by pointing to the path (which i’ve modified in teh mongod.conf) and nothing. Can you help me where I need to run this mkdir command?

Post a screenshot of the whole IDE so that we see exactly where and how you entered the commands.

here is the command and showing enter it doesn’t do anything or even say failed. I do this prior and/or after mongod or config file is opened. What step am i missing to be able to make the new directory and point to it?

Where do you enter the mongod command? We only see the mkdir.

In terminal 0 i connect to the mongod with “mongod” and then use “mkdir” command as shown above in the same terminal and again, nothing happens, I hit enter and nothing executes and i try to use the ls directory and nothing shows up either as if it would be created in the background.

Post a screenshot of that.

The mkdir command has to be run before starting mongod since mongod uses the directory.

Also post a screenshot of that.


I am not sure what I am doing wrong, please help.

user@M103# mkdir -p /var/mongodb/db
user@M103# mongod
2021-10-08T19:15:58.453+0000 I CONTROL [main] Automatically disabling TLS 1.0, to force-enable TLS 1.0 specify --sslDisabledProtocols ‘none’
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] MongoDB starting : pid=309 port=27017 dbpath=/data/db 64-bit host=xRFjFicMDnwVnw46k4
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] db version v4.0.5
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] git version: 3739429dd92b92d1b0ab120911a23d50bf03c412
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] OpenSSL version: OpenSSL 1.1.1g 21 Apr 2020
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] allocator: system
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] modules: none
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] build environment:
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] distarch: x86_64
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] target_arch: x86_64
2021-10-08T19:15:58.467+0000 I CONTROL [initandlisten] options: {}
2021-10-08T19:15:58.516+0000 I STORAGE [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2021-10-08T19:15:58.516+0000 I NETWORK [initandlisten] shutdown: going to close listening sockets…
2021-10-08T19:15:58.516+0000 I NETWORK [initandlisten] removing socket file: /tmp/mongodb-27017.sock
2021-10-08T19:15:58.516+0000 I CONTROL [initandlisten] now exiting
2021-10-08T19:15:58.516+0000 I CONTROL [initandlisten] shutting down with code:100
user@M103#

You have to start your mongod with config file
You issued just mongod.It will try to bring up mongod on default port and path
Since /data/db is not existing it failed to start

Your lab or exercise is to start mongod on specific port,path etc which are defined in your config file