Ubuntu – Connection failed to open the DB connection: could not find driver


I am newbie for Ubuntu and I was trying to run LAMP.

I installed MySQL, and PDO extensions. When I show the PHP config (with phpinfo()) it shows:

Configuration File (php.ini) Path: /etc/php5/apache2

Also I see mysql and pdo_mysql tables in the config output.

locate pdo_mysql.so giving: /usr/lib/php5/20090626+lfs/pdo_mysql.so

locate mysql.so giving:


in the php.ini file I enabled the extensions like this:



But that does not help

Then I enabled


still the same, no result,

after any changes I am restarting Apache2 with service apache2 restart

But still PHP can not locate PDO for opening connection.

So how can I get it work?

Best Answer

What version of Ubuntu? Are you sure you need to add those lines to php.ini?

I have versions 10.03 and 11.10, and both are similar in that none of that is in php.ini, but is in the directory under that one, called conf.d.

In conf.d/mysql.ini, I have:


In conf.d/pdo.ini, I have:


In conf.d/pdo_mysql.ini, I have:


I don't have the newest version, and I also don't use any special LAMP stack, just the standard apps I installed separately, if that makes any difference. But I never had any problems, and never had to explicitly install PDO that I can remember.