tags:

views:

471

answers:

3

I have just installed Debian Lenny with Apache, MySQL, and PHP and I am receiving a PDOException could not find driver.

This is the specific line of code it is referring to:

$dbh = new PDO('mysql:host=' . DB_HOST . ';dbname=' . DB_NAME, DB_USER, DB_PASS)

DB_HOST, DB_NAME, DB_USER, and DB_PASS are constants that I have defined. It works fine on the production server (and on my previous Ubuntu Server setup).

Is this something to do with my PHP installation?

Searching the internet has not helped, all I get is experts-exchange and examples, but no solutions.

A: 

Did you check your php.ini (check for the correct location with phpinfo()) if MySQL and the driver is installed correctly?

unset
@unset I am looking in php.ini, but what should I be looking for? I see a section that begins with `[MySQL]`
letseatfood
+1  A: 

You need to have a module called pdo_mysql. Looking for following in phpinfo(),

pdo_mysql

PDO Driver for MySQL, client library version => 5.1.44
ZZ Coder
@ZZ Coder This is not present in phpinfo(). Do you know how I can install `pdo_mysql`?
letseatfood
@ZZ Coder I was able to get it installed. Thank-you, I will accept your solution, since it was what I needed!
letseatfood
@letseatfood... How did you figure this out? I'm having the same problem!
Hristo
@Hristo I ended up scrapping my Debian Lenny installation for Ubuntu Server Edition, so I can't remember exactly. But, I think it is possible that I just installed `pdo_mysql`. Perhaps this link will help: http://blog.nethazard.net/how-to-install-php-pdo-on-debian-lenny/
letseatfood
@Hristo I think the `pdo_mysql` module did not come as a part of the default package in Debian Lenny
letseatfood
A: 
sudo apt-get install sqlite php5-sqlite
sudo /etc/init.d/apache2 restart

If your phpinfo() is not showing the pdo_sqlite line (in my case, on my Ubuntu Server), you just need to run the lines above and then you'll be good to go.

Hobbes of Calvin