LoginSignup
2
3

More than 3 years have passed since last update.

mac + homebrew + postgresSQLでバージョン違いのエラーが発生した時(database files are incompatible with server)

Posted at

macでpostgresSQLのcreatedbでのエラー解決

postgresSQLで新しいデータベースを作成しようとcreatedbコマンドを打つと
以下のようなエラーが発生した。

error_message
createdb: error: could not connect to database template1: 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"?

テンプレート1つながらず、サーバーにもつなげない、、、
エラー文を読んでもいまいちピンと来ないのでログを確認

ログの確認
% postgres -D /usr/local/var/postgres
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 12, 
      which is not compatible with this version 13.0.

どうやらデータディレクトリのバージョンが今使っているバージョンと違って
競合している為、使えないご様子。
そういうわけでデータディレクトリの方をアップグレード。

ログの確認
% postgres -D /usr/local/var/postgres
FATAL:  database files are incompatible with server
DETAIL:  The data directory was initialized by PostgreSQL version 12, 
      which is not compatible with this version 13.0.
データベースのアップグレード
 % brew postgresql-upgrade-database

無事にアップグレードが完了して、問題なくcreatedbも出来ました!よかった!

2
3
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
2
3