Brew services start but postgresql94 does not

675 Views Asked by At

Current situation:

I'm trying to install and run postgresql 9.4 via homebrew.

It installs fine, and when I run brew services start postgresql94, it says it started correctly.

However there is no postgres process running in ps and psql can't connect.

I can start it with postgres -D, but trying to log in via psql -U postgres tells me that the postgres role doesn't exist and I can't figure out another default to using. (my local user also doesn't exist as a role)

How I got here:

I'm trying to set up a new dev environment with an existing Rails 4.1.8 app.

I originally installed postgresql 9.5 via homebrew which worked happily until I attempted to migrate which failed with this error.

I cannot upgrade to a newer version of Rails. I've searched around a bunch and I'm surprised more people haven't run into this problem.

If you have any suggestions to either of the above I would really appreciate it.

1

There are 1 best solutions below

1
apotry On BEST ANSWER

You can create a new admin user with password 'secret':

psql -c "create role admin password 'secret' superuser createdb createrole inherit login";

or, try prepending sudo -u postgres bash -c

"sudo -u postgres bash -c psql -c \"create role ..\""

If this still gives you an error message such as 'FATAL: role "admin" does not exist", you might want to do a fresh install. On a fresh install you have a default superuser named 'postgres' with no password and you should be able to login with

psql -U postgres