我在一台虚拟机(Ubuntu)上使用XAMPP和PostgreSQL的Windows机器上安装了Laravel 4 . 我还在PostgreSQL机器(ubuntu)上编辑了以下文件,以便正常工作:
/etc/postgresql/9.1/main/pg_hba.conf
/etc/postgresql/9.1/main/postgresql.conf
In a raw php: 在我的Windows机器上我可以通过以下代码连接到远程机器上的PostgreSQL数据库,一切正常:
$dbconn = pg_connect("host=192.168.56.101 port=5432 dbname=gis user=gisuser password=mypass");
$sql="CREATE TABLE users (id varchar(5),name varchar(20),PRIMARY KEY(id))";
pg_exec($dbconn, $sql) or die(pg_errormessage());
现在用户表是在我的PostgreSQL数据库中创建的 .
But in Laravel: 我无法连接相同的配置 . 我在database.php中设置了所有内容,当我运行以下artisan命令时:
php artisan migrate:install
命令行中出现以下错误:
[PDOException]
SQLSTATE[08006] [7] could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (::1) and accepting
TCP/IP connections on port 5432?
could not connect to server: Connection refused (0x0000274D/10061)
Is the server running on host "localhost" (127.0.0.1) and accepting
TCP/IP connections on port 5432?
migrate:install [--database[="..."]]
有人可以帮我通过我的Windows机器上的Laravel 4连接到我的远程PostgreSQL服务器吗?