4
votes

I've decided to switch from MySQL to PostgreSQL recently, mostly just to learn a new DB. It's been pretty painful, but I think I'm close.

I'm using php and PDO, my PDO driver has been successfully install and configured.

Opening my site, I get the error:

Connection failed: SQLSTATE[08006] [7] FATAL: Ident authentication failed for user "postgres"

I'm using the following connection calls (I've tried a few variations of calling user/pw in the $dsn variable, and in separate $user/$pass variables, and including port=5432):

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

Also, I'm able to log into my db from the command line:

$ su postgres

(pass)

$ psql db1

output:

could not change directory to "/home/ec2-user" psql (8.4.9) Type "help" for help.

db1=#

Any ideas? I'd love to provide more info if needed.

1
Is your pg_hba.conf file all right? It's a known source of pain at the beginning w/ PostgreSQL... - maraspin
@maraspin: I just tried messing with that before refreshing this page. It worked. I had to switch some 'ident' values to 'trust'. Could you add that as an answer so I can accept? - Parris Varney
Sure. Answer added. Tnx. :-) PS Watch outh, though. Your security might be put at risk with settings which are too loose. Once you've identified that your problem resides there, I suggest you to take another glance at the pg_hba.conf documentation and act accordingly. You'll see... it's something you'll need w/ PostgreSQL anyways ;-) - maraspin

1 Answers

6
votes

Is your pg_hba.conf file all right? It's a known source of pain at the beginning w/ PostgreSQL. And, the situation you mention, is a good candidate for such kind of a problem. :-)