Is there a step to step guide to change the place where my MongoDB data is stored?

Hi everyone. I started with MongoDB a few days ago and noticed it installed in the local C drive.

I have my OS booting from that disk, so I wanted to make Mongo store its data on the D drive. When looking up ways to do it, I found about using --dbpath, as well as modifying the .config file on the “bin” folder. However, after doing both of those things, I noticed that everytime I made a change on a database, the updates where made on the C: folder where Mongo installed, rather than the folder I indicated with both the --dbpath and the config file (checked it did this because of the times the files where modified in there).

I definitely think I’m doing something wrong and I didn’t find any posts online that apply to the last version of MongoDB (6.0). Can anyone give a step by step guide to do this, that someone who just started on Mongo can follow?

Appreciate it!

I’m not sure why that happens. Every thing related to mongodb should be in that same folder. No idea.

But maybe you can work around it by creating a dump of your data (should be small since only few days) and restore it to a local server with different path.