2
3

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

問題発生

Rails動かそう。

$ bundle exec rails s

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

うごかない!

トラブルシューティング

PostgreSQLの初期化

ログをみましょう。
※場所は環境によって違うと思います

$ tail /usr/local/var/postgres.log

2018-12-19 08:53:41.889 JST [15860] FATAL:  database files are incompatible with server
2018-12-19 08:53:41.889 JST [15860] DETAIL:  The data directory was initialized by PostgreSQL version 10, which is not compatible with this version 11.1.

brew upgradeによってpostgresqlのバージョン上がってそれが問題になってそう。
初期化。

$ rm -rf /usr/local/var/postgres/
$ initdb /usr/local/var/postgres/ -E utf8

Rails動かします

再度Rails動かします。

$ bundle exec rake db:create

FATAL: role "username" does not exist

うごかない!

ユーザーを作成します。

$ createuser USERNAME

権限付与

$ psql -d postgres

postgres=# ALTER ROLE USERNAME WITH Superuser;
postgres=# \q

db作ってからうごかします

$ bundle exec rake db:create
$ bundle exec rails s

うごいた!

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

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?