Path | What Is The Default Database Path For MongoDB?

In this post, we will get to know What is the default database path for MongoDB where the location depends upon the operating system as Windows is different than Linux and mac so here we will get to know all the locations of all the operating systems.


By Default Path Of Databases

As there are different locations for each operating system so here we will get to know about all the possible os systems locations


Linux has a specific location to store the mongoDB database when we store it by default is ‘/data/ db’ in the mongoDB folder and the complete location will be ‘/val / lib/ MongoDB/ data/ db’ or ‘ /users /username /data /db’ in the private directory.

Mac OS

Even in case os Mac OS also we have the same location where we stored the file in the case of Linux which is nothing but ‘/var / lib/ MongoDB/ data/ db’ or ‘ /users /username /data /db’ where username is the name of the user who is using that account


In the case of the window, it is stored at ‘C \data \data \db’.

And of course, we can always change the location by simply following some steps given below.

  • locate the MongoDB configuration file. On Linux and macOS, it’s typically located at ‘etc /mongodb.conf On Windows, it’s typically located at ‘C:\Program Files\MongoDB\Server\6.0\bin’
  • Open the configuration file in a text editor and locate the stored section.
  • Add or modify the db Directory option to specify the desired database location.
  dbDirectory: C:\Program Files\MongoDB\Server\6.0\bin

Save the change to the configuration file.

Now we need to restart the mongoDB server for reflecting the changes we made.

Another way to change to location is to specify different directions during the start itself. which we had explained here with an example.

  • Open a command prompt or terminal window.
  • Start the MongoDB server with the db Directory option, specifying the desired database directories.

the command for the same is given below.

mongod --db Directory C:\Program Files\MongoDB\Server\6.0\bin
  • Add if necessary, some additional options to configure the MongoDB server as needed and make it easy to access when required.
  • Press Enter to start the server. and the task is done.


To learn more about What is the default database path for MongoDB visit:  default database directory

To learn more about MongoDB and tutorial related to it visit: MongoDB Problems And Tutorials

Leave a Comment

%d bloggers like this: