Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

PostgreSql 'PDOException' with message 'could not find driver'

pdo is working fine with mysql but with pgsql its giving error 'PDOException' with message 'could not find driver' I've installed php5-pgsql package which also includes pdo_pgsql

http://packages.debian.org/sid/php5-pgsql

This package provides a module for PostgreSQL database connections directly from PHP scripts. It also includes the pdo_pgsql module for use with the PHP Data Object extension.

my dsn is pgsql:dbname=DB;host=192.168.0.2 I am using Ubuntu 10.04

like image 891
Dipro Sen Avatar asked Apr 10 '12 07:04

Dipro Sen


2 Answers

This message means you need to install and or activate postgresql extension in PHP

This solution works for me : To install postgresql extension

[sudo] apt-get install php-pgsql 

after, for activating it, uncomment pgsql and pdo-pgsql extensions in etc/php/$PHP_VERSION/apache2/php.ini file

enter image description here

Finally, type :

[sudo] /etc/init.d/apache2 restart 

To restart apache server if you use apache such as was my case...

like image 98
Goms Avatar answered Oct 11 '22 18:10

Goms


1) Have you enabled pgsql.so in php.ini (extension=pgsql.so)?

2) Is you Postgresql listenin on 192.168.0.2 interface? (You can check it by netstat -tpln)

3) How you authenticate your access into Postgresql?

like image 37
Jan Marek Avatar answered Oct 11 '22 19:10

Jan Marek