postgresql - psql -h IP/localhost -U postgres -W/-w 不工作
问题描述
我正在尝试使用以下 2 个命令连接到 postgres DB,但无法连接到 DB:
- psql -h 10.xxx -U postgres -W
- psql -h localhost -U postgres -W
输出:
-bash-4.2$ psql -h 10.x.x.x -U postgres -W
Password:
psql: could not connect to server: Connection refused
Is the server running on host "10.54.48.59" and accepting
TCP/IP connections on port 5432?
-bash-4.2$
-bash-4.2$ psql -h localhost -U postgres -W
Password:
psql: FATAL: Ident authentication failed for user "postgres"
-bash-4.2$
但是当我尝试使用没有 IP 的命令连接到数据库时,它可以工作:
-bash-4.2$ psql -U postgres -W
Password:
psql (11.3)
Type "help" for help.
postgres=#
我也尝试在我的 pg_hba.conf 中包含以下列表:
host all all 127.0.0.1/32 ident
host all all 127.0.0.1/32 md5
host all all 127.0.0.1/32 password
解决方案
你可以试试...
host all all 127.0.0.1/32 trust
接着
psql -h localhost -U postgres DB
推荐阅读
- python - “gensim.models.word2vec”没有属性“KeyedVectors”
- c++ - 在 std::unordered_map 中插入新的键/值对会导致“超出范围”异常
- spring - 表单提交后转发到 Spring Controller 中的 JSP
- javascript - 转换多个打开时间和减少单个打开时间的问题
- sql - 根据大于子句更新 Select 中的值
- heroku - 将 Flask 应用程序部署到 Heroku 的困难
- java - 使用 Webflux 实现 POST
- java - 在java中将字符串输入到二维数组中
- python - 如何从一个元素执行 Python Selenium 多次循环?
- swift - 从 Firebase 获取图像时,tableView 不会滚动到 Swift 行