Change Default DB Path - Problem with path in configuration file

Good moring,
I cannot understand why the dirPath must be
/var/mongodb/db
rathen than
var/mongodb/db/

In my configuration the one asked as solution does not work (the /var/mongodb/db)
while the other /var/mongodb/db/) does work

How can I complete this lab and retrieve the code to continue?
Thanks

/ is the root folder of a linux file system. Since the folder var is a direct subfolder of the file systems root, it must be prefixes with /.

In case your more familiar with Windows: / is the equivalent to c:\

1 Like

Ok, thats right, but if I call mongod --options from the vagrant@m103:~$ terminal I can only start mongoD using var/mongodb/db/ and not using /var/mongodb/db.
In the second case mongod say: “Path does noth exist”.
But it exist, at least for me

When you define the path without the leading / it’s relative, so it should work if your currently in the root directory.

I’m not sure about the followin, it’s just a suggestion. Your working path has a trailing / but has your non-working path actually no such trailing /? Maybe some mysterious mechanism inside mongod identifies the path as a path to a file and not to a directory.

1 Like

Understood it was the problem.
I was creating the file in “User”/var beside /var
Thanks!