MongoDB "data/db" folder not existing error

Problem

You've installed MongoDB for WSL using these instructions. Congratulations!

You've typed mongod into your terminal:

mongod

And, suddenly you've got the following error:

2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] MongoDB starting : pid=22147 port=27017 dbpath=/data/db 64-bit host=Xanthic
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] db version v3.6.8
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] git version: 8e540c0b6db93ce994cc548f000900bdc740f80a
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] OpenSSL version: OpenSSL 1.1.1f  31 Mar 2020
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] allocator: tcmalloc
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] modules: none
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] build environment:
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten]     distarch: x86_64
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten]     target_arch: x86_64
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] options: {}
2021-01-22T20:35:38.444+1000 I STORAGE  [initandlisten] exception in initAndListen: NonExistentPath: Data directory /data/db not found., terminating
2021-01-22T20:35:38.444+1000 I CONTROL  [initandlisten] now exiting
2021-01-22T20:35:38.445+1000 I CONTROL  [initandlisten] shutting down with code:100
Picture of error after running mongod

Solution

It hasn't actually created the path "/data/db", so we'll go ahead and do that.

Last updated

Was this helpful?