Permission Denied for mkdir on Mac

Ok I don't know any linux command and just trying to follow the instructions in here:

So I opened the terminal and typed

mkdir -p /data/db

but it said Permission Denied.

What should I do?

5 Answers

Try this command:

sudo mkdir -p /data/db

sudo executes the command with higher privileges, and will ask for your password before it lets the command be executed.

3

You do not have permissions to create the directory. As you are trying to run this as your own user, and as I suspect /data/db is hardcoded somewhere, you should be able to do

sudo install -m 0755 -o $USER -d /data/db

This will use super user privileges (sudo) to create two directories (/data, and /data/db). /data/db would be owned by the user specified by -o - you ($USER) and will have 0755 permissions - owner with full permissions, and everyone read-only access. If the parent directories are missing, they will be created and owned by root (cannot find docs about this, but experiments confirm it).

I suggest you do it this way because the rest of the instructions you will still do as your own user.

1

Try this one:

mkdir -p data/db

No slash before the data

1

In OS X Catalina and higher /data became a reserved path

Had the same problem on mac os x. I solved this by executing sudo -p mkdir data, cd data and after this sudo -p mkdir db. Good luck.

You Might Also Like