我正在尝试在 Django 应用程序中设置 Django PostgreSQL。我为该用户创建了数据库、用户和密码,当我运行
\l
时,我可以看到该数据库。当我使用 python manage.py runserver
运行 django 应用程序时,我收到以下错误消息。
ON PURE START UP
USER TABLE NOT EXIST
connection to server at "localhost" (127.0.0.1), port 5432 failed: could not initiate GSSAPI security context: Unspecified GSS failure. Minor code may provide more information: Server not found in Kerberos database
connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: Ident authentication failed for user "postgres"
我错过了什么
类似的错误,但 php 应用程序从 docker 容器连接到本地主机上的 PostgreSQL
FastCGI sent in stderr: "PHP message: PHP Warning: pg_connect(): Unable to connect to PostgreSQL server: connection to server at "127.0.0.1", port 5432 failed: FATAL: Ident authentication failed for user
正如@jjanes 在评论中所写
sudo vim /var/lib/pgsql/data/pg_hba.conf
将
ident
更改为 md5
以进行密码验证
# host DATABASE USER ADDRESS METHOD [OPTIONS]
host all all 127.0.0.1/32 md5
需要重启
sudo systemctl restart postgresql