Postgres sh: /usr/local/var/postgres/server.log: no such file or directory

I recently had to reinstall homebrew and postgres, and now postgres does not work with rails.

First, trying to start s rails, I get the following:

/Users/lee/.rvm/gems/ ruby-1.9.3-p125@achievex /gems/activerecord-3.2.6/lib/active_record/connection_adapters/postgresql_adapter.rb:1206:in `initialize': could not connect to server: Connection refused (PG::Error) 

So, I'm trying to start postgres, and I get the following:

 pg_ctl -D /usr/local/var/postgres -l /usr/local/var/postgres/server.log start server starting sh: /usr/local/var/postgres/server.log: No such file or directory 

Postgres seems to be running because of this:

  ps aux | grep postgreslee 1099 0.3 0.0 2425480 188 s000 R+ 5:48PM 0:00.01 grep postgres 

I don’t understand at all why I cannot make it work.

+6
source share
1 answer

First, ps | grep actually pulls your grep from the process tree. Postgres does not work. This happens when the directory in which the journal is placed does not exist. Therefore, probably you are pointing it to a non-existent directory.

This can happen if you do not already have a data directory.

Recommendations:

  • Start by saying your data directory exists. look for pg_hba.conf and see if it is on your system. If so, then there is a good chance that it is in your data directory (if it is in, etc., then find base / 1 / PG_VERSION. This will be in your data directory one level above the base).
  • if it already exists, modify your postgresql.conf to set the logging setting accordingly and leave the -l option.
  • If the data directory does not exist, use the initdb command to create it.
+5
source

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


All Articles