Dealing with the MongoDB error /data/db not found in OSX
Disclaimer
if you landed somehow on this article, you have probably miss something in the install process of MongoDB.
What the.. ?
When trying to launch mongodb in your Terminal, I guess you have met with this kind of error message:
The output is pretty clear, you do not have the data
directory, and its db
subdirectory created in your root folder, which are essential to run the mongodb instance.
So let’s go ahead and fix that, and create that directory.
If you try to launch the mongod
command again after that, it will fail with something like the above:
The directory is created, but you do not have sufficient rights to interact with it.
Do I have the permission, Sir?
Fixing this error can be done by using the two commands below:
What it means on the first line is the owner have read, write, and execute rights, and others have only read and execute rights. The second line changes the ownership of the directory from its current owner to the logged in user.
Aaaaand, that’s it! Next time you will fire the mongod
command, you should see an output like this:
Wrapping up
Reading documentation is an essential part of being a software developer, it might not sound sexy, it’s sometimes tedious, but it’s an essential job to understand what you do and how things work.