You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

PostgreSQL登录报错:用户'postgres'密码验证失败的解决方法

解决PostgreSQL密码认证失败(实际为端口不匹配)问题

登录PostgreSQL时遇到如下错误:

psql: error: connection to server at "localhost" (127.0.0.1), port 5432 failed: FATAL: password authentication failed for user "postgres"

即使修改了postgres用户的密码,错误依然存在。经过排查,找到以下解决方案:

  • 检查PostgreSQL配置
    查看配置文件确认端口号:

    sudo nano /etc/postgresql/16/main/postgresql.conf
    
  • 确认端口号问题
    发现PostgreSQL 16实际运行在端口5433,而非默认的5432:

    port = 5433
    
  • 使用正确端口连接
    在连接命令中明确指定端口:

    psql -h localhost -U postgres -p 5433
    

调整后即可成功登录PostgreSQL。

内容的提问来源于stack exchange,提问作者Amr Maree

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.06.21 03:59:52