34

The php_pdo_mysql.dll can't be enabled in machine. I have set extension=php_pdo.dll and extension=php_pdo_mysql.dll enabled in php.ini, but when I checked phpinfo(), the item PDO drivers is no value.

and also I can't find the mysql infos in phpinfo() but I have set extension=php_mysql.dll enabled.

What's wrong ?

danorton
  • 11,804
  • 7
  • 44
  • 52
Hardy Lim
  • 341
  • 1
  • 3
  • 5

18 Answers18

74

I had this same problem when I upgraded to PHP 5.4. I had

extension_dir = "ext"

in php.ini and php -m was starting fine and reporting that it loaded pdo_mysql, but when I ran phpinfo.php through apache, the driver was missing.

I fixed it by changing the extension_dir to an absolute path. I'm guessing it got confused when running through Apache and made it relative to something else.

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "D:/php-5.4.11-Win32-VC9-x86/ext"
takteek
  • 7,020
  • 2
  • 39
  • 70
  • 1
    I bought a new computer and installed windows 7 ultimate 64 bits. Apache, PHP and MySQL are also 64 bits. My answer didn't work on this environment (using relative path), but takteek's answer did!! – Matías Cánepa Feb 17 '13 at 22:41
  • Spent hours searching for a solution, every site/post said to check the same settings. Checked everything over and over. Then a takteek appears and provides that solution that actually fixed the issue. Thank you. +1 – nxasdf Dec 14 '14 at 02:47
  • This solution still worked for me. I ran into the same issue with PHP 5.6.32 – Thomas Baumgartner Jan 04 '18 at 13:55
  • using absolute extension dir in php.ini for version that runs under apache worked for me (extension_dir = "C:/Programs/php/php-7.4.9-Win32-vc15-x64/ext" instead of extension_dir = "ext") – Homayoun Behzadian Aug 16 '20 at 07:38
12

try the following: look for this in your php.ini and uncomment extension_dir = "ext"

; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
 extension_dir = "ext"
Matías Cánepa
  • 5,770
  • 4
  • 57
  • 97
8

Try php -m in console, it will show startup errors of PHP.

Mihai Iorga
  • 39,330
  • 16
  • 106
  • 107
nzy
  • 161
  • 2
  • 3
8

On an Windows Server 2012, Apache 2.4, php 5.4 installation, after trying everything else changing this worked...

PHPIniDir "C:\php\"

to

PHPIniDir "C:/php/"

...guh.

Machavity
  • 30,841
  • 27
  • 92
  • 100
Gregg Seipp
  • 173
  • 2
  • 11
5

In PHP 7.1 x64 on windows with apache 2.4 x64:

extension_dir = "ext" doesn't work for me,

absolute path: extension_dir = "C:\DEV\PHP71\ext\" worked well

  • 1
    Please explain your answer code only answer doesn't help much. – Jeet Feb 26 '17 at 07:17
  • 2
    what code you want? This is setting in php.ini file, when I set extension_dir value to "ext" on my windows machine no ext was loaded till I changed value to absolute path of my PHP ext dir e.g. C:\DEV\PHP71\ext – Łabudziński Piotr Mar 08 '17 at 09:28
4

Check with phpinfo() to ensure that the path for the php.ini is the same one being set. On Windows machines it is common for multiple instances of php.ini to be created and cause confusion.

Also, calling php from the command line will give you an error message with more details as to why it may not be loading. It might be that the extension that you are trying to include is not compatible with your PHP installation. i.e. it is a non thread safe dll with a thread safe binary or there is a compiler mismatch somewhere where vc9 and vc6 were both used.

Steve Buzonas
  • 5,300
  • 1
  • 33
  • 55
3

After change the php.ini configuration, need to restart Appche server in windows service. Then the extension module will be loaded. use following code to test :<?php print_r(get_loaded_extensions());?>

Alexander
  • 31
  • 1
3

PDO Drivers no value - your dll entries cannot orderized in php.ini file. Check the list of dll extension entries.

extension=php_pdo_mysql.dll

entries must be placed next to all pdo entries. Same as

extension=php_mysql.dll

entries must be placed next to all without pdo entries.

Hops it helps..

Mohamed Mohaideen AH
  • 2,527
  • 1
  • 16
  • 24
2

I was having this problem on Windows using IIS. My php.ini contained the following sections:

[PHP_PDO_MYSQL]
extension=php_pdo_mysql.dll
[PHP_PDO]
extension=php_pdo.dll

I simply took the [PHP_PDO_MYSQL] and [PHP_PDO] sections, and swapped their positions, so that [PHP_PDO] came first. I guess declaration order is important!

2

Mihai's comment in 2012 says: "Try php -m in console, it will show startup errors of PHP." This suggestion proved to be most helpful. If there are any errors in the php.ini file, Windows PHP manager (IIS 8) is not very clear about what's wrong with php.ini.

Go to the Command Prompt and type php -m at the prompt. A pop-up message (alert) will let you know about any errors AND it gives line numbers for those problems. In most cases, my only issue was that I had uncommented (removed the semi-colon) on a few php.ini lines where I should NOT have done so.

Another helpful tip for me was to put in the full path for the extensions folder, (see comment above by Jeremy Prine) which helped with the "missing dll" messages started popping up in the alert boxes.

fracz
  • 20,536
  • 18
  • 103
  • 149
1

I had the same issue, and was stumped until I read the following:

http://www.artfulsoftware.com/php_mysql_win.html

I am running PHP 5.2 with Apache 2.2. The fix for me was to copy the libmysql.dll file into my Apache bin directory.

I would recommend the following course of action to anyone having this issue: 1) check to make sure that loaded configuration file is where you think it is (i.e., that Apache is not using some default php.ini) - phpinfo() will provide the answer on this 2) check to make sure that all desired extensions are located in the php\ext folder and are included in the php.ini file (most popular extensions simply need to be uncommented) 3) Try to load pdo_sqllite. If this shows up in phpinfo() after restarting Apache, you've narrowed the problem to the inability of Apache to load the necessary mysql extensions. 4) Follow in instructions in the link above.

user2014597
  • 31
  • 1
  • 4
1

If you're using PHP Manager with IIS, do the following:

  1. Open IIS (I usually open it by typing IIS in start); Start IIS

  2. Double-click "PHP Manager"; Click PHP Manager

  3. Click "Enable or disable an extension"; Enable/Disable extension

  4. Scroll down to find your driver of choice (in my case php_pdo_mysqll.dll), and click "enable"; Scroll to driver & enable

  5. After that the driver should show up, and work. Enabled driver

  6. Done! Hopefully this helped someone, because the other answers did not work for me.

Bono
  • 4,757
  • 6
  • 48
  • 77
1

I found my problem after lots of searching. In php.ini the extension directory was wrong. Check the slash direction. It should be backslashes as in following line. extension_dir = "C:\wamp\bin\php\php8.0.10\ext"

Incorrect: extension_dir = "C:/wamp/bin/php/php8.0.10/ext"

In wampserver also check phpForApache.ini for the same problem.

Jan
  • 21
  • 2
1

I got hints here:

http://wiki.cementhorizon.com/display/CH/Solution+-+Unable+to+load+dynamic+library+C+php+ext+php_mysql.dll+-+the+specified+module+could+not+be+found

I made sure that I set c:/php as a PATH variable and then moved the appropriate dlls into the c:/php directory (from the c:/php/ext directory).

All works for me now, though I'm not completely comfortable with moving things around the php directory.

axel22
  • 32,045
  • 9
  • 125
  • 137
tapertaper
  • 47
  • 1
  • 7
0

I had this problem too. I have Apache/2.2.22 (Win32) PHP/5.3.23 on a Windows 7 machine. My solution was changing extension_dir = C:\Program Files (x86)\PHP\ext in the php.ini file to extension_dir = "C:\Program Files (x86)\PHP\ext". It just needed adding the quotation marks.

I also added the php directory to the CLASSPATH.

thecla_032
  • 21
  • 2
  • 5
0

check that pdo*.dll files are in appropriate locations in OS directory, check references for these files are enabled in php.ini, check your dbconnection string is correct, restart apache

Bruno
  • 17
  • 4
0

PHP error PDO not exist on 5.4

Fatal error: Class 'DigitalToolBox\PDO' not found in C:\SERVER\www\MyAPP\DigitalToolBox\MysqlConnectionTool.php on line 19

you can see pdo is loaded because is in list with this comand:

print_r(get_loaded_extensions()); 

this error happens for the use of namespaces, we need to add at the beginning of our code the instruction:

use PDO;

IF ($this->works) $voteForThis++;

0

1.In php.ini, remove " around directory in etxnesion dir variable . It may looks like that :

extension_dir = c:\PHP\ext

  1. Copy The edited ini file (php.ini) to C:\windows dir

Then retstart appache !

Done!