php PDO 驱动程序在 Windows 中没有价值
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/7086859/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
PDO drivers no value in Windows
提问by Hardy Lim
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 driversis no value.
在php_pdo_mysql.dll
不能在机器中启用。我已经在 php.ini 中设置extension=php_pdo.dll
并extension=php_pdo_mysql.dll
启用了,但是当我检查时phpinfo()
,项目PDO driversis no value。
and also I can't find the mysql infos in phpinfo() but I have set extension=php_mysql.dll
enabled.
而且我在 phpinfo() 中找不到 mysql 信息,但我已设置为extension=php_mysql.dll
启用。
What's wrong ?
怎么了 ?
回答by takteek
I had this same problem when I upgraded to PHP 5.4. I had
当我升级到 PHP 5.4 时,我遇到了同样的问题。我有
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.
在 php.ini 中,并且php -m
开始正常并报告它加载了 pdo_mysql,但是当我通过 apache 运行 phpinfo.php 时,驱动程序丢失了。
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.
我通过将 更改extension_dir
为绝对路径来修复它。我猜它在运行 Apache 时会感到困惑,并将其与其他东西相关联。
; 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"
回答by Matías Cánepa
try the following: look for this in your php.ini and uncomment extension_dir = "ext"
尝试以下操作:在您的 php.ini 中查找并取消注释extension_dir = "ext"
; Directory in which the loadable extensions (modules) reside.
; http://php.net/extension-dir
; extension_dir = "./"
; On windows:
extension_dir = "ext"
回答by nzy
Try php -m
in console, it will show startup errors of PHP.
php -m
在控制台中尝试,它会显示PHP的启动错误。
回答by Gregg Seipp
On an Windows Server 2012, Apache 2.4, php 5.4 installation, after trying everything else changing this worked...
在 Windows Server 2012、Apache 2.4、php 5.4 安装上,在尝试了其他一切更改后,这一切都奏效了……
PHPIniDir "C:\php\"
to
到
PHPIniDir "C:/php/"
...guh.
……唔。
回答by ?abudziński Piotr
In PHP 7.1 x64 on windows with apache 2.4 x64:
在带有 apache 2.4 x64 的 Windows 上的 PHP 7.1 x64 中:
extension_dir = "ext" doesn't work for me,
extension_dir = "ext" 对我不起作用,
absolute path:extension_dir = "C:\DEV\PHP71\ext\" worked well
绝对路径:extension_dir = "C:\DEV\PHP71\ext\" 运行良好
回答by Steve Buzonas
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.
检查 phpinfo() 以确保 php.ini 的路径与设置的路径相同。在 Windows 机器上,通常会创建多个 php.ini 实例并导致混淆。
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.
此外,从命令行调用 php 会给您一条错误消息,其中包含有关为什么它可能无法加载的更多详细信息。可能是您尝试包含的扩展与您的 PHP 安装不兼容。即它是一个具有线程安全二进制文件的非线程安全 dll,或者在使用 vc9 和 vc6 的地方存在编译器不匹配。
回答by Alexander
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());?>
更改php.ini配置后,需要在windows服务中重启Appche服务器。然后将加载扩展模块。使用以下代码进行测试:<?php print_r(get_loaded_extensions());?>
回答by Bravo F Yankee
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.
米海在2012年的评论说:“在控制台尝试php -m,它会显示PHP的启动错误。” 这个建议被证明是最有帮助的。如果 php.ini 文件中有任何错误,Windows PHP 管理器 (IIS 8) 就不太清楚 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.
转到命令提示符并php -m
在提示符下键入。弹出消息(警报)将让您了解任何错误,并提供这些问题的行号。在大多数情况下,我唯一的问题是我在一些我不应该这样做的 php.ini 行上取消了注释(删除了分号)。
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.
对我来说另一个有用的提示是放入扩展文件夹的完整路径,(见上面 Jeremy Prine 的评论)这有助于“缺少 dll”消息开始在警报框中弹出。
回答by Jeremy Prine
I was having this problem on Windows using IIS. My php.ini contained the following sections:
我在使用 IIS 的 Windows 上遇到了这个问题。我的 php.ini 包含以下部分:
[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!
我只是拿了[PHP_PDO_MYSQL]
和[PHP_PDO]
部分,并交换了他们的位置,所以[PHP_PDO]
先来了。我想声明顺序很重要!
回答by Bono
If you're using PHP Managerwith IIS, do the following:
如果您在IIS 中使用PHP 管理器,请执行以下操作:
Open IIS (I usually open it by typing IIS in start);
Double-click "PHP Manager";
Click "Enable or disable an extension";
Scroll down to find your driver of choice (in my case
php_pdo_mysqll.dll
), and click "enable";After that the driver should show up, and work.
Done! Hopefully this helped someone, because the other answers did not work for me.
打开 IIS(我通常在开始时输入 IIS 来打开它);
双击“PHP管理器”;
点击“启用或禁用扩展”;
向下滚动以找到您选择的驱动程序(在我的情况下
php_pdo_mysqll.dll
),然后单击“启用”;之后司机应该出现并工作。
完毕!希望这对某人有所帮助,因为其他答案对我不起作用。