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 postgresqlBut I can't connect PostgreSQL server like this command. And it displayed these errors.
psql postgrespsql: 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 postgresqlAnd also tried this answer, but this file did not exist in the directory.
1 Answer
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