Postgres - 致命的: データベースファイルはサーバーと互換性がありません 質問する

Postgres - 致命的: データベースファイルはサーバーと互換性がありません 質問する

MacBook Pro を再起動した後、データベース サーバーを起動できません。

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

ログを確認すると、次の行が何度も表示されます。

FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 9.2, which is not compatible with this version 9.0.4.

9.0.4 は Mac にプリインストールされていたバージョンで、9.2[.4] は Homebrew 経由でインストールしたバージョンです。

前述のように、これは再起動前は機能していたため、実際にはコンパイルの問題ではない可能性があります。再実行しましたinitdb /usr/local/var/postgres -E utf8が、ファイルはまだ存在しています。

ベストアンサー1

最近postgres を最新バージョンにアップグレードした場合は、以下のコマンドを実行して、すべてのデータを保持したまま postgres データ ディレクトリをアップグレードできます。

brew postgresql-upgrade-database

上記のコマンドは、brew info postgres

注意: 最近のテストでは、これは 14 から 15 へのアップグレードには機能しません。postgres バージョン > 14 の場合は、pg_upgradeクラスターを直接アップグレードする必要があります。

おすすめ記事