dongre6227 2013-04-18 13:46
浏览 71
已采纳

Php连接到postgresql

$dbconn = pg_connect("host=localhost   dbname=mydbname   user=myuser    password=mypass") or die(pg_last_error());

returns Unable to connect to PostgreSQL server: FATAL: no pg_hba.conf entry for host "::1 ...",

What I must do?

P.S. In file php.ini modul extension php_pgsql.dll is enabled

  • 写回答

1条回答 默认 最新

  • dorbmd1177 2013-04-19 00:59
    关注

    This or this would've helped you determine the nature of the problem.

    It looks like you're trying to connect over IPv6 (hence ::1) and the host's pg_hba.conf doesn't have a rule allowing you to connect from the IPv6 loopback address (::1) as user myuser to database mypass.

    I suspect the server is misconfigured; to work around it try specifying the host as 127.0.0.1 (the IPv4 loopback address) instead of localhost, or just omit the host= completely to use unix domain sockets if PHP supports that.

    Your statement "When use mysql (on remote server), as host value we can use host=localhost right?" is completely nonsensical for both MySQL and PostgreSQL. If it's a remote server then it is by definition not on localhost. At a wild guess I think you might be trying to say that the server is remote in the sense that it's not the computer you are working on, but it's local to the program you are running because you are running the program on the remote server (by editing it on the remote server, uploading the program text over FTP, or whatever).

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥20 求数据集和代码#有偿答复
  • ¥15 关于下拉菜单选项关联的问题
  • ¥20 java-OJ-健康体检
  • ¥15 rs485的上拉下拉,不会对a-b<-200mv有影响吗,就是接受时,对判断逻辑0有影响吗
  • ¥15 使用phpstudy在云服务器上搭建个人网站
  • ¥15 应该如何判断含间隙的曲柄摇杆机构,轴与轴承是否发生了碰撞?
  • ¥15 vue3+express部署到nginx
  • ¥20 搭建pt1000三线制高精度测温电路
  • ¥15 使用Jdk8自带的算法,和Jdk11自带的加密结果会一样吗,不一样的话有什么解决方案,Jdk不能升级的情况
  • ¥15 画两个图 python或R