Yii Framework Forum: PostgreSQL connection problems - Yii Framework Forum

Jump to content

Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

PostgreSQL connection problems Rate Topic: -----

#1 User is offline   jmolins 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 21-February 09

Posted 24 February 2009 - 06:33 PM

Hi,

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:
'db'=>array(
                'connectionString'=>'pgsql:host=localhost;port=5432;dbname=testdrive',
                'username'=>'jmolins',
                'password'=>'mypass',
),

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.

Jose
0

#2 User is offline   jmolins 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 21-February 09

Posted 24 February 2009 - 06:48 PM

Update:

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."
0

#3 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 24 February 2009 - 08:15 PM

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.
0

#4 User is offline   jmolins 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 4
  • Joined: 21-February 09

Posted 25 February 2009 - 05:05 AM

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

It is documented in http://es.php.net/ma...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.
******
0

#5 User is offline   qiang 

  • Yii Project Lead
  • Yii
  • Group: Yii Dev Team
  • Posts: 5,875
  • Joined: 04-October 08
  • Location:DC, USA

Posted 25 February 2009 - 07:23 AM

That's good know. Thank you very much!
0

#6 User is offline   flak 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 1
  • Joined: 12-August 12

Posted 12 August 2012 - 02:29 AM

Hi,
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:
'db'=>array(
'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:
'db'=>array(
'connectionString' => 'pqsql:dbname=dbDeadMansSwitch;user=postgres;password=admin',
'class'=>'application.extensions.PHPPDO.CPdoDbConnection',
'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.

PLEASE HELP!!!
0

#7 User is offline   KimWangLee 

  • Newbie
  • Yii
  • Group: Members
  • Posts: 2
  • Joined: 15-June 11

Posted 13 August 2012 - 03:17 PM

@flak,

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
'db'=>array(
    'connectionString'=>'pgsql:host=localhost;port=5432;dbname=mydbname',
    'username'=>'myusername',
    'password'=>'mypass',
),

0

Share this topic:


Page 1 of 1
  • You cannot start a new topic
  • You cannot reply to this topic

1 User(s) are reading this topic
0 members, 1 guests, 0 anonymous users