0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【PostgreSQL】サーバーを起動時にエラーが発生

Posted at

エラーの発生内容

ActiveRecord :: ConnectionNotEstablished
PG::ConnectionBad: 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"?

やったこと

  • PC自体を再起動 → NGだった
  • psql -Vを実行
  • バージョンがpsql (PostgreSQL) 14.1
  • brew services listを実行
  • postgresql が error
  • tail -n 20 /usr/local/var/log/postgres.logを実行
2022-02-04 05:55:21.403 JST [4050] FATAL:  database files are incompatible with server
2022-02-04 05:55:21.403 JST [4050] DETAIL:  The data directory was initialized by PostgreSQL version 13, which is not compatible with this version 14.1.
2022-02-04 05:55:31.536 JST [4118] FATAL:  database files are incompatible with server

以下省略
:
:
:

解決方法

PostgreSQLのメジャーアップデートが原因で,データベースが読めないケースと推察。
以下を順に実行

brew services stop postgresql
==> Successfully stopped `postgresql`
brew upgrade postgresql
Warning: postgresql 14.1_1 already installed
rm -rf /usr/local/var/postgres.old

brew postgresql-upgrade-database
==> Upgrading postgresql data from 13 to 14...

省略



==> Upgraded postgresql data from 13 to 14!
==> Your postgresql 13 data remains at /usr/local/var/postgres.old
brew services start postgresql
==> Successfully started `postgresql`
brew services list
postgresql    started

やっぱり互換性が問題だったみたいですね;;
とにかく解決できてよかったーー。

0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?