1.登录
1.1 psql报错
详情+分析:
C:\Users\Administrator>pgsql
'pgsql' 不是内部或外部命令,也不是可运行的程序
或批处理文件。
# 命令错误
C:\Users\Administrator>psql
用户 Administrator 的口令:
psql: 错误: 致命错误: 用户 "Administrator" Password 认证失败
# 将对应的可执行文件路径添加到系统‘环境变量’,如:F:\Program Files\PostgreSQL\13\bin
C:\Users\Administrator>psql
用户 Administrator 的口令:
psql: 错误: fe_sendauth: no password supplied
# 需要指定用户
C:\Users\Administrator>psql -u postgres
psql: illegal option -- u
尝试 "psql --help" 以得到更多信息.
C:\Users\Administrator>psql -U postgres
用户 postgres 的口令:
psql: 错误: 致命错误: 用户 "postgres" Password 认证失败
参考:https://blog.csdn.net/gghhm/article/details/104279508
1.2 psql: 错误: 致命错误: 用户 “postgres” Password 认证失败
报错:
C:\Users\Administrator>psql -U postgres
用户 postgres 的口令:
psql: 错误: 致命错误: 用户 "postgres" Password 认证失败
解决方法:
- 找到postgreSQL的配置文件 pg_hba.conf ,如:
F:\Program Files\PostgreSQL\13\data
- 找到“IPv4 local connections”,把编码方式改成md5,如:
host all all 0.0.0.0/0 md5
- 重启服务
services postgresql restart
- 连接数据库
C:\Users\Administrator>psql -U postgres 用户 postgres 的口令: psql (13.3) 输入 "help" 来获取帮助信息.
参考:psql: 致命错误: 对用户"postgres"的对等认证失败的解决方法
https://blog.csdn.net/weixin_34390996/article/details/86260833