0

My environment

macOS Mojave 10.14.6 Homebrew 2.1.11 PostgreSQL 11.5

I typed brew command and checked PostgreSQL server is running.

brew services start postgresql

But I can't connect PostgreSQL server like this command. And it displayed these errors.

psql postgres

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"?

How can I solve this problem?

I've already tried to restart PostgreSQL server

brew services restart postgresql

And also tried this answer, but this file did not exist in the directory.

https://stackoverflow.com/a/18832331/5062103

1 Answer 1

6

I solved this problem as below.

First, run the database.

postgres -D /usr/local/var/postgres
2019-09-01 03:27:51.272 JST [5002] FATAL:  database files are incompatible with server
2019-09-01 03:27:51.272 JST [5002] DETAIL:  The data directory was initialized by PostgreSQL version 9.6, which is not compatible with this version 11.5.

It displayed incompatible version errors.

Second, remove the old database.

rm -rf /usr/local/var/postgres 

Third, initialize new one.

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

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .