小编Fra*_*ens的帖子

PHP无法连接到CentOS 7上的PostgreSQL

我在OSX上的VirtualBox中运行了CentOS 7.Apache,PHP 5.4和PostgreSQL 9.2都在运行.但是,当我的(简单)php脚本尝试连接到PostgreSQL时,它不起作用:

警告:pg_connect():无法连接到PostgreSQL服务器:无法连接到服务器:权限被拒绝服务器是否在主机"127.0.0.1"上运行并接受端口5432上的TCP/IP连接?在第7行的/var/www/html/pg.php中

检查:

  • Apache正在运行
  • PHP很好,phpinfo()告诉我PostgreSQL函数是可用的
  • PostgreSQL 9.2正在运行
  • psql可以使用localhost或127.0.0.1以及192.168.178.111连接到数据库
  • 我的Mac上的pgAdmin可以使用IP地址192.168.178.111连接到此数据库
  • iptables已被关闭
  • pg_hba.conf已被更改为接受所有连接而没有任何密码(愚蠢,我知道):

托管所有0.0.0.0/0信任

但是php无法连接....这是我的脚本:

<?php
ini_set('display_errors', 1);
error_reporting(E_ALL);

echo 'hello world!';

$conn = pg_connect('host=127.0.0.1 port=5432 user=postgres dbname=postgres');
?>
Run Code Online (Sandbox Code Playgroud)

内部连接工作(psql),外部连接也工作(我的笔记本电脑上的pgAdmin),但PHP连接不起作用...

出了什么问题?我错过了什么?

php postgresql centos centos7

6
推荐指数
1
解决办法
4238
查看次数

postgres - 错误:运算符不存在

同样,我有一个在本地运行良好的函数,但将它移到网上会产生一个很大的错误......从有人指出我传递的参数数量不准确的回应中得到提示,我加倍 -在这种情况下检查以确保我将 5 个参数传递给函数本身......

Query failed: ERROR: operator does not exist: point <@> point HINT: No operator matches the given name and argument type(s). You may need to add explicit type casts.
Run Code Online (Sandbox Code Playgroud)

查询是这样的:

BEGIN; SELECT zip_proximity_sum('zc',                                                                                                                                                                  
    (SELECT g.lat FROM geocoded g                                                                                                                                                                              
    LEFT JOIN masterfile m ON g.recordid = m.id                                                                                                                                                                
    WHERE m.zip = '10050' ORDER BY m.id LIMIT 1),                                                                                                                                                             
    (SELECT g.lon FROM geocoded g                                                                                                                                                                              
    LEFT JOIN masterfile m ON g.recordid = m.id                                                                                                                                                                
    WHERE m.zip = '10050' ORDER BY m.id LIMIT 1), …
Run Code Online (Sandbox Code Playgroud)

postgresql postgis

5
推荐指数
2
解决办法
5580
查看次数

标签 统计

postgresql ×2

centos ×1

centos7 ×1

php ×1

postgis ×1