LoginSignup
0
0

Postgresqlの注意点

Posted at

prismaを使った時にPostgresqlではまったので、忘れないように備忘録として残しておく。

Postgresqlで自分は下記のエラーにはまった。

Error: P1000: Authentication failed against database server at `localhost`, the provided database credentials for `postgres` are not valid.

Please make sure to provide valid database credentials for the database server at `localhost`.

このエラーと同時にログを見ると

2024-06-16 19:19:01.541 JST [269] LOG:  database system is ready to accept connections
2024-06-16 19:20:36.275 JST [1714] postgres@blog_nextjs_crud FATAL:  password authentication failed for user "postgres"
2024-06-16 19:20:36.275 JST [1714] postgres@blog_nextjs_crud DETAIL:  User "postgres" has no password assigned.
        Connection matched file "/etc/postgresql/16/main/pg_hba.conf" line 125: "host    all             all             127.0.0.1/32            scram-sha-256"
2024-06-16 19:50:58.307 JST [7667] postgres@blog_nextjs_crud FATAL:  password authentication failed for user "postgres"
2024-06-16 19:50:58.307 JST [7667] postgres@blog_nextjs_crud DETAIL:  User "postgres" has no password assigned.
        Connection matched file "/etc/postgresql/16/main/pg_hba.conf" line 125: "host    all             all             127.0.0.1/32            scram-sha-256"
2024-06-16 19:51:22.893 JST [7854] postgres@blog_nextjs_crud FATAL:  password authentication failed for user "postgres"
2024-06-16 19:51:22.893 JST [7854] postgres@blog_nextjs_crud DETAIL:  User "postgres" has no password assigned.
        Connection matched file "/etc/postgresql/16/main/pg_hba.conf" line 125: "host    all             all             127.0.0.1/32            scram-sha-256"

またある人からpostgresユーザーがパスワードを再設定をしたらどうかと言われていろいろ調べました。

で結論Postgresqlのパスワードなしでもいけるということが調べて分かり、下記のように設定変更。

pg_hba.conf
# "local" is for Unix domain socket connections only
local   all             all                                     trust
# IPv4 local connections:
host    all             all             127.0.0.1/32            trust
# IPv6 local connections:
host    all             all             ::1/128                 trust

これでpostgresユーザーでパスワードなしでいけるかなって実行したらいけました。

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