43
23

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 5 years have passed since last update.

PostgreSQLが起動できなくなっていた時の対処法

Posted at

状況

新しくアプリを作る際に、以前PostgreSQLで作成していたアプリを参考にしようと思ってDBを覗こうとしたらPostgresに接続できなくなっていた。

psql -l

結果、下記のようなエラーが出てポスグレに接続出来ない

psql: 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 -D /usr/local/var/postgres
[2960] FATAL:  database files are incompatible with server
[2960] DETAIL:  The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.2.

どうやらポスグレのバージョンがおかしいらしい
ということで、

brew postgresql-upgrade-database

このコマンドを実行したところ、

==> Upgraded postgresql data from 10 to 11!
==> Your postgresql 10 data remains at /usr/local/var/postgres.old
==> Successfully started `postgresql` (label: homebrew.mxcl.postgresql)

アップグレードに成功し、

psql -l
                                       List of databases
           Name           | Owner  | Encoding |   Collate   |    Ctype    |  Access privileges  
--------------------------+--------+----------+-------------+-------------+---------------------
 hoge_development | hoge | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 
 hoge_test        | hoge | UTF8     | en_US.UTF-8 | en_US.UTF-8 | 

psqlコマンドも使えるようになり、接続できるようになった。

43
23
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
43
23

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?