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

lampMySQLPHP

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:

/usr/lib/perl5/auto/DBD/mysql/mysql.so
/usr/lib/php5/20090626+lfs/mysql.so
/usr/lib/php5/20090626+lfs/pdo_mysql.so
/usr/lib/pyshared/python2.7/_mysql.so
/usr/lib/python2.7/dist-packages/_mysql.so

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

extension=/usr/lib/php5/20090626+lfs/mysql.so

extension=/usr/lib/php5/20090626+lfs/pdo_mysql.so

But that does not help

Then I enabled

extension=mysql.so
extension=pdo_mysql.so

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:

extension=mysql.so

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

extension=pdo.so

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

extension=pdo_mysql.so

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.