PostgreSQL connection problems


I am having problems connecting to the PostgreSQL server.

Following the Definitive guide, inside the yiic shell, I receive the following error:

>> model testuser

exception 'CDbException' with message 'CDbConnection failed to open the DB connection: SQLSTATE[08006] [7] FATAL:  Ident authentication failed for user "jmolins"' in /var/www/html/yii/framework/db/CDbConnection.php:233

My configuration in main.php is:






I think everything should be ok. In fact, using phpPGAdmin I can correctly connect using the previous jmolins/mypass user.

I have seen in the PostgreSQL docs that connection string should be of the form:

'pgsql:host=localhost port=5432 dbname=testdrive user=jmolins password=mypass'

Without the semicolons (not as in mysql) and including user and password.

I do not know if this could be an issue.

Any Ideas?

How can I see where php is failing?

Thanks a lot.



According to the PostgreSQL site, semi-colons should be the way to separate the attributes. So, that should not be the problem.

"The PDO_PGSQL DSN should be seperated by semi-colons not spaces. It should follow the convention like the rest of the PDO DSNs."

The format of your configuration (with semicolons) is correct. That is also what we are using for this yii site.

My only suggestion is to double check your U/P.

The error message comes from PDO. So nothing we can do here.

I write how I solved this issue in case someone faces the same.

It is documented in…k.pdo.php#69963.

Depending on the configuration in postgresql.conf, the hostname and port should not be included in the connection string.

you should try to leave the host= and port= parts out of the connection string. This sounds strange, but this is an "option" of Postgre. If you have not activated the TCP/IP port in postgresql.conf then postgresql doesn't accept any incoming requests from an TCP/IP port. If you use host= in your connection string you are going to connect to Postgre via TCP/IP, so that's not going to work. If you leave the host= part out of your connection string you connect to Postgre via the Unix domain sockets, which is faster and more secure, but you can't connect with the database via any other PC as the localhost.

That's good know. Thank you very much!


I am having a major Postgres connection problem that I have spend hours and hours researching and trying to solve:

With this in my main.php file:


'connectionString' => 'pqsql:dbname=dbDeadMansSwitch;user=postgres;password=admin',	


I get this error:

CDbConnection failed to open the DB connection: could not find driver

Then if I modify/add the following to main.php:


'connectionString' => 'pqsql:dbname=dbDeadMansSwitch;user=postgres;password=admin',	


'pdoClass' => 'PHPPDO',		


I get this error:

Alias "application.extensions.PHPPDO.CPdoDbConnection" is invalid. Make sure it points to an existing PHP file and the file is readable.



the build of your connectionString is wrong

user and password dont belongs to that string

here is an example to connect to a pgsql-database