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

RAILS_ENV=production rails db:create db:migrate コマンドがエラーになる時の対処法

Posted at

Railsアプリのpriduction環境用のデータベースを作成するときに、RAILS_ENV=production rails db:create db:migrateコマンドを実行したのですがエラーが発生しました。

$ RAILS_ENV=production rails db:create db:migrate

FATAL:  Peer authentication failed for user "test_2"

Couldn't create 'hello_rails_production' database. Please check your configuration.

rails aborted!

PG::ConnectionBad: FATAL:  Peer authentication failed for user "test_2"

/home/horikoshi5/hello_rails/bin/rails:9:in `<top (required)>'

/home/horikoshi5/hello_rails/bin/spring:15:in `<top (required)>'

bin/rails:3:in `load'

bin/rails:3:in `<main>'

Tasks: TOP => db:create

(See full trace by running task with --trace)

 

これを解決するには、/etc/postgresql/11/main/pg_hba.confファイル(11の所は入っているpostgresqlのバージョンによって異なります)の


local   all             all                                     peer

を下記のように変更すれ必要があります。


local   all             all                                     md5

 

そして最後にpostgresqlを再起動すれば完了です。

$ sudo systemctl restart postgresql.service 

参考

[https://ryotatake.hatenablog.com/entry/2019/05/03/postgresql_peer_authentication_failed:title]

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?