Kyle Decot
Kyle Decot

Reputation: 20815

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?

Upvotes: 10

Views: 8373

Answers (3)

Jim Diamond
Jim Diamond

Reputation: 1274

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.

Upvotes: 2

Mike
Mike

Reputation: 309

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.

Upvotes: 10

Antoine
Antoine

Reputation: 1344

sudo chown -R `whoami` /usr/local

Upvotes: 25

Related Questions