2

I have a CentOs 6.7 server. I have problem to make pdo_mysql available on apache2. following shows for Command line:

myserver$ php -m
PDO, pdo_mysql, pdo_sqlite

but phpinfo(), shows only PDO and pdo_sqlite

I already included following in php.ini

extension=pdo_mysql.so
extension=pdo.so

And restarted the Apache with:

sudo service httpd restart

It looks like, pdo_mysql is installed on a different php. when I search the server for pdo.so and pdo_mysql.so, I get pdo.so in three places, but pdo_mysql in two places.

myserver$ locate pdo.so
/usr/lib64/php/modules/pdo.so
/usr/lib64/php-zts/modules/pdo.so
/var/opt/remi/php56/root/usr/lib64/php/modules/pdo.so

myserver$ locate pdo_mysql.so
/usr/lib64/php/modules/pdo_mysql.so
/usr/lib64/php-zts/modules/pdo_mysql.so

And Apache installation in phpinfo() shows:

Loaded Configuration File   /opt/remi/php56/root/etc/php.ini 

So my recent php upgrade to php 5.6 is missing pdo_mysql. other php installation has it, but I don't know how to force the pdo_mysql installation to install it to /var/opt/remi/php56/

I used following for installing pdo-mysql:

yum install pdo-mysql

So, it installed it under /usr/lib64/php/ but not under /var/opt/remi/php56/.

3 Answers 3

3

It seems you are confused by the 2 available PHP stacks in remi repository.

  • php-* packages = base packages with configuration in /etc
  • php56-php-* packages = software collections for parallel installation with configuration in /opt

Also see the FAQ

And Apache installation in phpinfo() shows: Loaded Configuration File /opt/remi/php56/root/etc/php.ini

This means you are using the SCL version. So you need php56-php-mysqlnd

I already included following in php.ini

You never have to change the php.ini, each package provides its configuration file which enable the extension (and ensure correct load order, e.g. pdo "before" pdo_mysql)

I recommend you follow the Configuration Wizard results

0
1

You have installed PHP through the Remi repository.

Try this:

yum --enablerepo=remi,remi-php56 install php-pdo_mysql

That should keep your PHP installation nicely in sync.

2
  • Thanks JayMcTee. But it did not work! this is what I got in response: Loaded plugins: fastestmirror, priorities, rhnplugin, security This system is receiving updates from RHN Classic or Red Hat Satellite. Setting up Install Process Loading mirror speeds from cached hostfile * remi: mirrors.mediatemple.net * remi-php56: mirrors.mediatemple.net * remi-safe: mirrors.mediatemple.net remi | 2.9 kB 00:00 remi/primary_db | 1.4 MB 00:00 No package pdo-mysql available. Error: Nothing to do Mar 15, 2016 at 19:29
  • "pdo-mysql" is not correct, for "foo" extension use php-foo, (so php-pdo_mysql which is provided by php-mysqlnd package or php56-php-pdo_mysql provided by php56-php-mysqlnd). See my answer below. Mar 16, 2016 at 7:37
0

In case anyone comes across this later on, there's another solution that's very easy to miss.

I had the exact same issue as OP where pdo_mysql wouldn't load correctly and the module was installed.

Like the OP, I had mine loaded in with pdo_mysql then pdo on the line after it. That won't actually work.

extension=pdo
extension=pdo_mysql

Load the extensions in the above order. pdo has to go first, followed by any other pdo_* module. Once I changed the order around then restarted nginx and php-fpm, the PDO driver loaded properly.

This is server agnostic and not specific to any distro.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .