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

15,130

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.

Share:
15,130

Related videos on Youtube

elbek
Author by

elbek

Updated on September 18, 2022

Comments

  • elbek
    elbek over 1 year

    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?

  • elbek
    elbek almost 12 years
    I found answer. In php.ini we need to point where is the extensions are located. So I wrote in php.ini: extension_dir = "/usr/lib/php5/ext" I created /usr/lib/php5/ext folder then all .so files(mysql.so, pdo_mysql.so, ...) files i copied to there then restart server with service apache2 restart It worked. So important thing is extension_dir Make sure it is pointing to correct folder which has all .so files.
  • Deepak Verma
    Deepak Verma almost 12 years
    Well, mine isn't set up like that at all, but I guess as long as it works, that's what matters. Mine just has extension_dir = "./".