MongoDB /data/db folder permission problems

MongoDB solution for / data / db folder permission problem with an example and easy to follow guide on how to solve this problem on your PC or Server.

MongoDB is a document database with the scalability and flexibility that you want with the querying and indexing that you need. And I think it’s a really great Database but sometimes it’s just a pain!

What is MongoDB

MongoDB is a cross-platform document-oriented database, with the scalability and flexibility that you want with the querying and indexing that you need for big NoSQL databases.

As said MongoDB is classified as a NoSQL database program, and uses JSON-like documents with optional schemas. MongoDB is developed by MongoDB Inc. and licensed under the Server Side Public License.

Permission denied

I have had multiple times that I was getting the ‘Unable to create/open lock
file: /data/db/mongod.lock errno:13 Permission denied’ message!

And everytime I was searching the net to get a solution. Until now! I’ll just
write a little article with all my found solutions so I don’t need to search
for it again (as from now, I know it’s on my own site :-). I did the same with
the solution for removing git files or folders.

errno:13 Permission denied

So, you’ve got a lock error on your Mongod.

MongoDB folder permission solution

It could be a real permission error. So just set the rights right.

sudo chown mongod:mongod /data/db

If you get a “chown: mongod: Invalid argument” message…. it might be that
/data/db does not exists.

So do a:

sudo mkdir -p /data/db

That might work!

More info on MongoDB

  • MongoDB stores data in flexible, JSON-like documents, meaning fields can vary from document to document and data structure can be changed over time;
  • The document model maps to the objects in your application code, making data easy to work with;
  • Ad hoc queries, indexing, and real time aggregation provide powerful ways to access and analyze your data;
  • MongoDB is a distributed database at its core, so high availability, horizontal scaling, and geographic distribution are built in and easy to use;
  • MongoDB is free to use. Versions released prior to October 16, 2018 are published under the AGPL. All versions released after October 16, 2018, including patch fixes for prior versions, are published under the Server Side Public License (SSPL) v1.

Did you find this article valuable?

Support Theo van der Sluijs by becoming a sponsor. Any amount is appreciated!