无法通过Laravel SQLSTATE连接到PgSQL [08006] [7]致命 [英] Cannot connect to PgSQL via Laravel SQLSTATE[08006] [7] FATAL

查看:1095
本文介绍了无法通过Laravel SQLSTATE连接到PgSQL [08006] [7]致命的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图通过laravel连接到pgsql,最后进行了所有设置(正在运行pgsql服务器,已安装pdo,已安装所有库).我正在通过CPanel/WHM管理的VPS(CentOS)上运行.

I'm trying to connect to pgsql via laravel and finally got everything setup (pgsql server running, pdo installed, all libs installed). I'm running on a VPS (CentOS) managed via CPanel/WHM.

这是我在做什么: 我正在尝试使用migration:install通过artisan(Laravel的命令行)创建用户数据库.

Here's what I'm doing: I'm trying to create a user database via artisan (Laravel's command line) using migrate:install.

对于那些不使用Laravel的人,工匠使用pgsql的php PDO进行连接.这是我的设置:

For those that don't use Laravel, artisan uses php's PDO for pgsql to connect. Here are my settings:

    'pgsql' => array(
        'driver'   => 'pgsql',
        'host'     => 'localhost',
        'database' => 'dbname',
        'username' => 'username',
        'password' => 'password',
        'charset'  => 'utf8',
        'prefix'   => '',
    ),

我还设置了一个test.php文件:

I've also setup a test.php file:

$dbconn = pg_connect("host=localhost port=5432 dbname=dbname user=username password=password");

,这也会失败.我使用phpPgAdmin查看最新信息,所有权限均已正确设置,数据库显示出来,用户名正确,密码相同.我检查了postgre(版本8.4.12 btw)在哪里运行,并且phpPgAdmin告诉我"localhost:5432".

which also fails. I used phpPgAdmin to see what's up and all of the permissions are set correctly, the database shows up, the username is correct, same with password. I checked where postgre (version 8.4.12 btw) was running and phpPgAdmin tells me "localhost:5432".

我通过命令行得到的错误如下:

The error I get via the command line is the following:

SQLSTATE[08006] [7] FATAL: no pg_hba.conf entry for host "::1", user "myusername", database "my_database", SSL OFF

现在,我试图找到pg_hba.conf文件,但我不确定要在哪里查找. pg的错误/访问日志也一样,到目前为止,谷歌没有任何帮助.

Now, I tried to find the pg_hba.conf file but I'm not entirely sure where to look for it. Same goes for the error/access logs for pg and google hasn't been any help as far as this goes.

关于我能做什么的任何想法?

Any idea on what I can do?

推荐答案

localhost指向系统上的IPV6 :: 1地址.在处理访问列表时,PostgreSQL使ipv6和ipv4地址有所不同.

localhost points to IPV6 ::1 address on your system. Postgresql makes the difference between ipv6 and ipv4 addresses when dealing with access list.

这篇关于无法通过Laravel SQLSTATE连接到PgSQL [08006] [7]致命的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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