Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

initdb /usr/local/var/postgres on El Capitan

I'm attempting to run initdb /usr/local/var/postgres after installing postgresql 9.5 via homebrew on El Capitan but I get the following:

The files belonging to this database system will be owned by user "kyledecot".
This user must also own the server process.

The database cluster will be initialized with locale "en_US.UTF-8".
The default database encoding has accordingly been set to "UTF8".
The default text search configuration will be set to "english".

Data page checksums are disabled.

fixing permissions on existing directory /usr/local/var/postgres ... initdb: could not change permissions of directory "/usr/local/var/postgres": Operation not permitted

When attempting to cd /usr/local/var/postgres I get:

cd: permission denied: /usr/local/var/postgres

It appears that I don't have the proper permission to do this. I assume this has something to do w/ El Capitan's System Integrity Protection but I could be wrong.

How do I go about fixing this?

like image 505
Kyle Decot Avatar asked Jan 14 '16 19:01

Kyle Decot


3 Answers

sudo chown -R `whoami` /usr/local

like image 170
Antoine Avatar answered Oct 07 '22 00:10

Antoine


I had to combine two bits of advice that I have seen with Stack Overflow questions related to this question/error. I found myself in a chicken and an egg situation where I would reinstall postgres and change permissions one at a time, but both commands conflicted with each other.

So I did this:

sudo chown -R `whoami` /usr/local && brew postinstall postgresql

...and it worked fine.

like image 25
Mike Avatar answered Oct 06 '22 22:10

Mike


I find it not really efficient and secure to chown all /usr/local directory, so I did simply mkdir /usr/local/var/postgres

And all went smooth.

like image 2
Xentatt Avatar answered Oct 06 '22 23:10

Xentatt