Fedora系统VS Code终端无法连接PostgreSQL数据库求助
本地Fedora系统PostgreSQL连接失败求助
在本地Linux Fedora系统中无法连接PostgreSQL服务器,已确认这是PostgreSQL的特定问题,与Django/Python无关。
执行python manage.py migrate时持续报错:
django.db.utils.OperationalError: connection to server at "localhost" (::1), port 5432 failed: FATAL: Ident authentication failed for user "postgres"
已尝试的操作
- 将pg_hba.conf文件中的认证方式从
ident改为trust,尝试后无效;再改为md5,仍无效 - 执行
sudo service postgresql restart重启PostgreSQL服务
当前pg_hba.conf配置
# TYPE DATABASE USER ADDRESS METHOD # "local" is for Unix domain socket connections only local all all md5 # IPv4 local connections: host all all 127.0.0.1/32 md5 # IPv6 local connections: host all all ::1/128 md5 # Allow replication connections from localhost, by a user with the # replication privilege. # local replication all peer # host replication all 127.0.0.1/32 ident # host replication all ::1/128 ident
PostgreSQL最新日志
2025-01-06 16:26:51.273 MST [5612] LOG: database system was shut down in recovery at 2025-01-06 14:08:38 MST 2025-01-06 16:26:51.275 MST [5612] LOG: database system was not properly shut down; automatic recovery in progress 2025-01-06 16:26:51.288 MST [5612] LOG: redo starts at 0/37DB2C8 2025-01-06 16:26:51.288 MST [5612] LOG: invalid record length at 0/37DB300: expected at least 24, got 0 2025-01-06 16:26:51.288 MST [5612] LOG: redo done at 0/37DB2C8 system usage: CPU: user: 0.00 s, system: 0.00 s, elapsed: 0.00 s 2025-01-06 16:26:51.298 MST [5720] LOG: checkpoint starting: end-of-recovery immediate wait 2025-01-06 16:26:51.309 MST [5720] LOG: checkpoint complete: wrote 3 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.002 s, sync=0.002 s, total=0.013 s; sync files=2, longest=0.001 s, average=0.001 s; distance=0 kB, estimate=0 kB; lsn=0/37DB300, redo lsn=0/37DB300 2025-01-06 16:27:06.387 MST [6596] ERROR: canceling statement due to user request 2025-01-06 16:27:06.387 MST [6584] ERROR: canceling statement due to user request 2025-01-06 16:27:06.399 MST [5720] LOG: shutting down 2025-01-06 16:27:06.401 MST [5720] LOG: checkpoint starting: shutdown immediate 2025-01-06 16:27:06.420 MST [5720] LOG: checkpoint complete: wrote 0 buffers (0.0%); 0 WAL file(s) added, 0 removed, 0 recycled; write=0.001 s, sync=0.001 s, total=0.021 s; sync files=0, longest=0.000 s, average=0.000 s; distance=0 kB, estimate=0 kB; lsn=0/37DB3B0, redo lsn=0/37DB3B0
内容的提问来源于stack exchange,提问作者Corveloper
相关产品推荐
相关产品推荐

