Homebrew postgres broken Homebrew postgres broken postgresql postgresql

Homebrew postgres broken


I had the same problem installing postgres using homebrew on a freshly installed Yosemite.

First off my brew config looks like this:

HOMEBREW_VERSION: 0.9.5ORIGIN: https://github.com/Homebrew/homebrewHEAD: 9f6926265f8e4be7cc80dfe9042f2cd3c1e8dc9eLast commit: 64 minutes agoHOMEBREW_PREFIX: /usr/localHOMEBREW_CELLAR: /usr/local/CellarCPU: quad-core 64-bit sandybridgeOS X: 10.10.1-x86_64Xcode: 6.1.1Clang: 6.0 build 600X11: N/ASystem Ruby: 2.0.0-481Perl: /usr/bin/perlPython: /usr/bin/pythonRuby: ~/.rvm/rubies/ruby-2.1.1/bin/ruby

First thing i noticed was that I had no write permission to /usr/local/var/postgres. This was easily changed issuing sudo chown -R `whoami` /usr/local/var/postgres then I reinstalled postgresql and did

cat /usr/local/var/postgres/server.log

which revealed:

postgres cannot access the server configuration file "/usr/local/var/postgres/postgresql.conf": No such file or directory

So I removed the directory /usr/local/var/postgres and issued the command to initialize the database.

initdb -D /usr/local/var/postgres/

This seemed to have done the trick and postgres is running fine.


I had this same problem. The primary issue here is that the initdb step of installation will create the directory with root ownership instead of as the user on a Mac. To solve this issue:

Create the data directory before running initdb and set permissions of 0700

rm -rf /usr/local/var/postgres  # in case this is not your first trymkdir /usr/local/var/postgreschmod 0700 /usr/local/var/postgres

Then run initdb and it will respect the permissions of the data directory.

initdb -D /usr/local/var/postgres

For grins and giggles, create a test db named after your user:

createdb `whoami`

Login to test:

psql


After trying to install postgresql with Homebrew, I got this:

Warning: postgresql-9.5.2 already installed, it's just not linked

So I tried:

brew link postgresql

And got this error:

Linking /usr/local/Cellar/postgresql/9.5.2... Error: Could not symlink share/man/man3/SPI_connect.3/usr/local/share/man/man3 is not writable.

It seemed to be a write permission matter, so I did:

sudo chown -R `whoami` /usr/local/share/man/

It did the trick because, then I was able to do (without error):

brew link postgresql