😕
Postgres が起動しなくなったら
同様の記事は沢山あるけど、自分用にメモ。
発生したエラー
$ psql
psql: error: could not connect to server: 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"?
雑に brew service から再起動させてみる
$ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
$ psql
psql: error: could not connect to server: 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"?
状態変わらず。
Postgres を起動させてみる
$ postgres -D /usr/local/var/postgres
2020-12-24 20:52:11.632 JST [15536] FATAL: lock file "postmaster.pid" already exists
2020-12-24 20:52:11.632 JST [15536] HINT: Is another postmaster (PID 406) running in data directory "/usr/local/var/postgres"?
lock file が残ってるので消してみる
$ rm /usr/local/var/postgres/postmaster.pid
brew service から再起動
$ brew services restart postgresql
Stopping `postgresql`... (might take a while)
==> Successfully stopped `postgresql` (label: homebrew.mxcl.postgresql)
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)
psql 接続
$ psql
psql (12.3)
Type "help" for help.
tetsuya=#
( ˘ω˘ )
Discussion