“致命:主机没有pg_hba.conf条目”但是我可以通过pgAdmin连接 [英] "FATAL: no pg_hba.conf entry for host" but I can connect trough pgAdmin

查看:136
本文介绍了“致命:主机没有pg_hba.conf条目”但是我可以通过pgAdmin连接的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在基于CakePHP的项目的开发环境中遇到了一些麻烦。
问题是,CakePHP可以在生产环境中连接,但是如果我在PC上运行XAMPP槽,则会抛出
FATAL:主机 myexternalip没有pg_hba.conf条目,用户 dbuser,数据库 dbname,SSL已关闭



,但使用相同的参数,我可以通过pgAdmin通过PC连接。 / p>

我尝试了一些谷歌搜索技巧,例如从<$ c $复制 libpq.dll c> c:\xampp\php 到 c:\xampp\apache\bin ,但没有运气,已经检查了 pnp.ini extension = php_pdo_pgsql.dll 行没有注释,曾尝试过几次重启apache但没有任何变化



该项目托管在heroku平台下,而我的 /app/config/database.php 看起来是

  public $ production = array(
'datasource'=>'Database / Postgres',
'persistent'=> false,
'host'=>'anywhere.at.amazonaws.com',
'login'=>'dbuser',
‘密码’=> ‘dbpwd’,
‘database’=> ‘dbname’,
‘encoding’=> ‘utf8’,
);

这是堆栈跟踪

 -核心\模型\数据源\DboSource.php行260→Postgres-> connect()
-核心\模型\ConnectionManager.php第105行→DboSource-> __ construct(array)
-CORE\Cake\Model\Model.php第3613行→ConnectionManager :: getDataSource(string)
-CORE\Cake\Model \Model.php第1155行→Model-> setDataSource(string)
-CORE\蛋糕\Model\php.Model行3640→Model-> setSource(string)
-CORE \Cake\Model\Model.php第827行→Model-> getDataSource()

谁能给我另一个有用的提示?

解决方案

在我找到解决方案之后。



问题不是那么简单。



由于Postgres服务器托管在heroku平台下,因此服务器上的默认配置为 require ssl,所以我遇到了以下配置:

  public $ production = array(
......
sslmode'=> ‘require’,
);

现在错误已更改为 sslmode值 require在ssl时无效支持未编译



然后我用Google搜索了它,看来至少在XAMPP v5.5.19下, PHP文件夹中的libpq.dll 没有使用ssl支持进行编译



以下是帮助我解决此问题的问题:
< a href = https://stackoverflow.com/questions/23726779/how-to-installpostgresql-client-library-for-php-on-windows-with-ssl-enabled>如何在Windows上为PHP安装PostgreSQL客户端库启用S​​SL的



似乎pgAdmin的 libpq.dll 是使用ssl支持进行编译的,因此我可以通过pgAdmin而不是通过php进行连接的原因



感谢帮助人员!


I'm having a little trouble with my dev environment for a CakePHP based project. The thing is, CakePHP can connect in production, but if I run trough XAMPP on my PC, then throws me a FATAL: no pg_hba.conf entry for host "myexternalip", user "dbuser", database "dbname", SSL off

but using the same parameters I can connect from my PC trough pgAdmin.

I've tried some googling tips that I've found like copy the libpq.dll from c:\xampp\php to c:\xampp\apache\bin but, no luck, had checked pnp.ini and extension=php_pdo_pgsql.dll line is uncommented, had tried reboot apache several times but nothing changes

The project is hosted under heroku platform and my /app/config/database.php looks like

public $production = array(
    'datasource' => 'Database/Postgres',
    'persistent' => false,
    'host' => 'anywhere.at.amazonaws.com',
    'login' => 'dbuser',
    'password' => 'dbpwd',
    'database' => 'dbname',
    'encoding' => 'utf8',
);

here's the Stack Trace

- CORE\Cake\Model\Datasource\DboSource.php line 260 → Postgres->connect()
- CORE\Cake\Model\ConnectionManager.php line 105 → DboSource->__construct(array)
- CORE\Cake\Model\Model.php line 3613 → ConnectionManager::getDataSource(string)
- CORE\Cake\Model\Model.php line 1155 → Model->setDataSource(string)
- CORE\Cake\Model\Model.php line 3640 → Model->setSource(string)
- CORE\Cake\Model\Model.php line 827 → Model->getDataSource()

Can anyone give me another hint that could help?

解决方案

After while I found a solution.

The problem is that's not straightforward.

As the Postgres server is hosted under heroku platform, the default configuration on server is require ssl, so I've came across to this configuration:

public $production = array(
    ......
    'sslmode' => 'require',
);

Now the error has changed to a sslmode value "require" invalid when ssl support is not compiled

then I've googled it and seems that at least under XAMPP v5.5.19, the libpq.dll inside PHP folder wasn't compiled with ssl support

here's the question that helped me solve this problem: How to installPostgreSQL client library for PHP on Windows with SSL enabled

Seems that pgAdmin's libpq.dll was compiled with ssl support, so that is the cause that I could connect through pgAdmin, but not with php

thanks for help folks!

这篇关于“致命:主机没有pg_hba.conf条目”但是我可以通过pgAdmin连接的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆