1
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 1 year has passed since last update.

【PostgreSQL】ログインが出来ない場合の対応について

Posted at

環境

CentOS7
PostgreSQL 11.18

エラーについて

下記コマンドを実行したらエラーが出た。

$ psql -U hoge postgres
psql: FATAL: ユーザ "hoge" で対向(peer)認証に失敗しました

対応方法

重要

postgresユーザーのパスワードが未設定の場合は1番はじめに設定する

$ psql -U postgres

postgres=> ALTER USER postgres WITH ENCRYPTED PASSWORD 'password';

pg_hba.confで設定を変更する

vi /var/lib/pgsql/11/data/pg_hba.conf

変更箇所は下記の通り

~
# TYPE  DATABASE        USER            ADDRESS                 METHOD
# "local" is for Unix domain socket connections only
- local   all             all                                     peer
+ local   all             all                                     md5
~

最後にPostgreSQLを再起動する

systemctl reload postgresql-11.service

再度ログインを試してみる

$ psql -U hoge postgres
Password for user hoge:
psql (11.18)
Type "help" for help.

postgres=>
1
0
1

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