Permission Denied for mkdir on Mac
Solution 1:
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.
Solution 2:
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.
Solution 3:
Try this one:
mkdir -p data/db
No slash before the data
Solution 4:
In OS X Catalina and higher /data
became a reserved path https://bombich.com/kb/ccc5/working-apfs-volume-groups