请检查 pg_hba.conf 看看有没有你对应的IP的访问控制。没有的话就加上一行并重起 pgsql,默认情况下pgsql 对127.0.0.1 是信任的

解决方案 »

  1.   

    检查下pg_hba.conf,里面有访问权限的控制,还有你启动数据库的时候要加上 -i 选项,以允许tcp ip连接,应用程序一般都是通过tcp ip连接的。
      

  2.   

    能告诉我一下启动用-i命令怎么写吗?刚接触postgressql
      

  3.   

    查一下postmaster的帮助 启动postgresql server的时候简单加上-i参数就可以了bash-2.05b# postmaster --help
    postmaster is the PostgreSQL server.Usage:
      postmaster [OPTION]...Options:
      -B NBUFFERS     number of shared buffers
      -c NAME=VALUE   set run-time parameter
      -d 1-5          debugging level
      -D DATADIR      database directory
      -F              turn fsync off
      -h HOSTNAME     host name or IP address to listen on
    +++++++++++++++++++++++++++++++++++++++++++++++
      -i              enable TCP/IP connections   +
    +++++++++++++++++++++++++++++++++++++++++++++++
      -k DIRECTORY    Unix-domain socket location
      -l              enable SSL connections
      -N MAX-CONNECT  maximum number of allowed connections
      -o OPTIONS      pass "OPTIONS" to each server process
      -p PORT         port number to listen on
      -S              silent mode (start in background without l
    ogging output)
      --help          show this help, then exit
      --version       output version information, then exitDeveloper options:
      -n              do not reinitialize shared memory after ab
    normal exit
      -s              send SIGSTOP to all backend servers if one
     dies
      

  4.   

    输入了下面的命令:
    postmaster -D "data" -h 202.61.11.116 -p 5432 -i出现的错误信息是;
    Warning: pg_connect(): Unable to connect to PostgreSQL server: could not connect to server: Connection refused (0x0000274D/10061) Is the server running on host "202.61.11.116" and accepting TCP/IP connections on port 5432? in C:\apache\Apache2\htdocs\test\test.php on line 10我已经在pg_hba.conf里添加:
    host    all         all         202.61.11.116      255.0.0.0   trust
    请大家帮我解决一下
      

  5.   

    202.61.11.116的子网mask应该是 255.255.255.0吧?
      

  6.   

    另外 确认一下postgresql.conf里面 tcpip_socket=true
      

  7.   

    你启动数据库应该是在数据据服务器上起的啊,为什么用-h呢,直接用
    postmaster -i -D "数据库目录" & 启动数据库,不知道你用什么开发的项目,象tomcat做WEB服务器的一般多用连接池连接数据库的,配置一下就可以了,C语言的用PQsetdb()之类的函数就可以连接。