0

I am using Windows 10 and have installed Apache2.4, PHP7.2 and MySQL. I am having trouble installing the driver for pdo_mysql

I have edited my php.ini file, and in the extensions section I have:

extension=pdo_mysql

I have also set the extension_dir directive to:

"C:\php72\ext"

In the command console I enter "php -m" and I can see PDO and pdo_mysql both listed.

command console screenshot showing php -m

I have restarted Apache but when I run a .php file including either print_r(PDO::getAvailableDrivers()); or phpinfo(); I can see that I do not have any drivers installed for PDO.

In my httpd.conf file I have

PHPIniDir “C:\php72\”

I have tried changing this to use forward and backslashes, and including and removing the trailing slash, restarting Apache after each change. I still cannot get the pdo_mysql driver to load.

It seems to me that the problem is with Apache not with PHP (as the pdo_mysql module appears when I run php -m in the command console), but I don't understand what I have done wrong. I searched for other people having the same problem but the solution always seemed to be the PHPIniDir, which I think I have set correctly.

The machine I am using was already running IIS so I have Apache listening to port 8090, rather than the default. I am not sure if this is relevant or not.

Any help would be appreciated!

  • PHPIniDir is in the file httpd-xampp.conf in your apache installation folder, perhaps C:\xampp\apache\conf\extra\httpd-xampp.conf, and the line should look something like <IfModule php7_module> PHPINIDir "C:/xampp/php" </IfModule>. – harrymc Sep 22 at 10:44
  • Thanks but I didn't use xampp to install, so I don't have a C:\xampp directory, and I don't have a httpd-xampp.conf file either. – Liam Bell Sep 22 at 16:51
  • My PHPIniDir did not appear inside the IfModule tag as you suggested. I tried wrapping it inside those tags and restarting Apache, but the driver is still not loading. <IfModule php7_module> PHPIniDir “C:/php72/” AddHandler application/x-httpd-php .php LoadModule php7_module "C:\php72\php7apache2_4.dll" </IfModule> – Liam Bell Sep 22 at 17:02
0

I uninstalled Apache service, deleted C:\Apache24 and installed from scratch, the followed the steps to install pdo_mysql as before which has worked.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.