小编mar*_*pin的帖子

无法通过php pdo驱动程序连接到postgreSQL数据库

我最近决定从MySQL切换到PostgreSQL,主要是为了学习新的数据库.这真是太痛苦了,但我觉得我很亲近.

我正在使用php和PDO,我的PDO驱动程序已经成功安装和配置.

打开我的网站,我收到错误:

Connection failed: SQLSTATE[08006] [7] FATAL: Ident authentication failed for user "postgres"
Run Code Online (Sandbox Code Playgroud)

我正在使用以下连接调用(我尝试了在$ dsn变量中调用user/pw的一些变体,以及单独的$ user/$ pass变量,包括port = 5432):

$dsn  = 'pgsql:dbname=db1;host=localhost;user=postgres;password=pass';
$db = new PDO($dsn);
Run Code Online (Sandbox Code Playgroud)

此外,我可以从命令行登录我的数据库:

$ su postgres
Run Code Online (Sandbox Code Playgroud)

(通过)

$ psql db1
Run Code Online (Sandbox Code Playgroud)

输出:

无法将目录更改为"/ home/ec2-user"psql(8.4.9)输入"help"获取帮助.

DB1 =#

有任何想法吗?如果需要,我很乐意提供更多信息.

php postgresql pdo

4
推荐指数
1
解决办法
1万
查看次数

标签 统计

pdo ×1

php ×1

postgresql ×1