Running postgres server on Mac

I have this problem for the third or fourth time, when after rebooting my Mac (Yosemite and the same with the previous OSX version) the postgres server does not start. I installed my postgres after this link. Any idea why this happens after every restart?

typing psql he gives

 psql: could not connect to server: No such file or directory Is the server running locally and accepting connections on Unix domain socket "/tmp/.s.PGSQL.5432"? 
+6
source share
2 answers

I just fixed it on my mac. I used homebrew to install postgres. These are the steps that I took to get up and run again.

First check the status of the postgresql service:

 pg_ctl -D /usr/local/var/postgres status 

if you see this pg_ctl: no server running , unload the launch agent:

 launchctl unload ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 

then move the existing postgres data (moving, not deleting - cheap insurance):

 mv /usr/local/var/postgres /usr/local/var/postgres-deletemewhenitsallgood 

then initialize your postgres database:

 initdb /usr/local/var/postgres -E utf8 

then load the launch agent:

 launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist 

OR run it:

 pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start 

Now check the status again:

 pg_ctl -D /usr/local/var/postgres status 

If you see something like this, you are good to go.

 pg_ctl: server is running (PID: 61295) /usr/local/Cellar/postgresql/bin/postgres "-D" "/usr/local/var/postgres" 

Then you can enter your postgres database:

 psql -d postgres 
+23
source

Run postgres server on mac:

install postgres using brew

 brew install postgres 

make sure you have permissions for / usr / local / postgres

 sudo chown -R `whoami` /usr/local 

then run db:

initdb /usr/local/var/postgres

To launchd launch postgresql at login:

ln -sfv /usr/local/opt/postgresql/*.plist ~/Library/LaunchAgents

To download postgresql:

launchctl load ~/Library/LaunchAgents/homebrew.mxcl.postgresql.plist

To check your version:

psql --version

And to access postgres

psql -d postgres

+3
source

Source: https://habr.com/ru/post/981799/


All Articles