4

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.

3
  • Is your pg_hba.conf file all right? It's a known source of pain at the beginning w/ PostgreSQL... Commented Nov 4, 2011 at 1:19
  • 1
    @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? Commented Nov 4, 2011 at 1:22
  • 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 ;-) Commented Nov 4, 2011 at 1:26

1 Answer 1

6

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. :-)

Sign up to request clarification or add additional context in comments.

2 Comments

I had to change the values from ident to trust for my local and IPv4 records. Finally, I have a fully working LAPP(5.4) server going. Thanks!
Glad you've found the source for your problem. Now that you know exactly where to put your hands on, I suggest you to take a peek at the PostgreSQL documentation, so to properly configure the pg_hba.conf file. Can be important for your security.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.