PostgreSQL之pgsql命令行常用命令

21 篇文章 2 订阅


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 认证失败

解决方法:

  1. 找到postgreSQL的配置文件 pg_hba.conf ,如:F:\Program Files\PostgreSQL\13\data
  2. 找到“IPv4 local connections”,把编码方式改成md5,如: host all all 0.0.0.0/0 md5
  3. 重启服务 services postgresql restart
  4. 连接数据库
    C:\Users\Administrator>psql -U postgres
    用户 postgres 的口令:
    psql (13.3)
    输入 "help" 来获取帮助信息.
    

参考:psql: 致命错误: 对用户"postgres"的对等认证失败的解决方法
https://blog.csdn.net/weixin_34390996/article/details/86260833

2.常用操作

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值