Cannot connect to PgSQL via Laravel SQLSTATE[08006] [7] FATAL(无法通过 Laravel SQLSTATE [08006] [7] FATAL 连接到 PgSQL)
问题描述
我正在尝试通过 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.
这就是我正在做的事情:我正在尝试使用 migrate: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 的,artisan 使用 php 的 PDO 进行 pgsql 连接.这是我的设置:
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.
知道我能做什么吗?
推荐答案
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 [08006] [7] FATAL 连接到 PgSQL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:无法通过 Laravel SQLSTATE [08006] [7] FATAL 连接到 PgSQL
基础教程推荐
- Libpuzzle 索引数百万张图片? 2022-01-01
- mysqli_insert_id 是否有可能在高流量应用程序中返回 2021-01-01
- XAMPP 服务器不加载 CSS 文件 2022-01-01
- WooCommerce 中选定产品类别的自定义产品价格后缀 2021-01-01
- 在 Woocommerce 中根据运输方式和付款方式添加费用 2021-01-01
- 在 PHP 中强制下载文件 - 在 Joomla 框架内 2022-01-01
- 通过 PHP SoapClient 请求发送原始 XML 2021-01-01
- 在多维数组中查找最大值 2021-01-01
- 如何在 PHP 中的请求之间持久化对象 2022-01-01
- 超薄框架REST服务两次获得输出 2022-01-01