php 此适配器需要 PDO 扩展,但未加载扩展
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/2386575/
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
The PDO extension is required for this adapter but the extension is not loaded
提问by neo
I am getting the following exception when i try to use the fetchall method of the Zend_Db_Table_Abstract class...
当我尝试使用 Zend_Db_Table_Abstract 类的 fetchall 方法时,出现以下异常...
An error occurred4545
EXCEPTION_OTHER
Exception information:
Message: The PDO extension is required for this adapter but the extension is not loaded
Stack trace:
#0 D:\www\TestProject\library\Zend\Db\Adapter\Pdo\Mysql.php(96): Zend_Db_Adapter_Pdo_Abstract->_connect()
#1 D:\www\TestProject\library\Zend\Db\Adapter\Abstract.php(448): Zend_Db_Adapter_Pdo_Mysql->_connect()
#2 D:\www\TestProject\library\Zend\Db\Adapter\Pdo\Abstract.php(238): Zend_Db_Adapter_Abstract->query('DESCRIBE `album...', Array)
#3 D:\www\TestProject\library\Zend\Db\Adapter\Pdo\Mysql.php(156): Zend_Db_Adapter_Pdo_Abstract->query('DESCRIBE `album...')
#4 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(823): Zend_Db_Adapter_Pdo_Mysql->describeTable('albums', NULL)
#5 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(862): Zend_Db_Table_Abstract->_setupMetadata()
#6 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(969): Zend_Db_Table_Abstract->_setupPrimaryKey()
#7 D:\www\TestProject\library\Zend\Db\Table\Select.php(100): Zend_Db_Table_Abstract->info()
#8 D:\www\TestProject\library\Zend\Db\Table\Select.php(78): Zend_Db_Table_Select->setTable(Object(Application_Model_Albums))
#9 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(1005): Zend_Db_Table_Select->__construct(Object(Application_Model_Albums))
#10 D:\www\TestProject\library\Zend\Db\Table\Abstract.php(1303): Zend_Db_Table_Abstract->select()
#11 D:\www\TestProject\application\controllers\IndexController.php(17): Zend_Db_Table_Abstract->fetchAll()
#12 D:\www\TestProject\library\Zend\Controller\Action.php(513): IndexController->indexAction()
#13 D:\www\TestProject\library\Zend\Controller\Dispatcher\Standard.php(289): Zend_Controller_Action->dispatch('indexAction')
#14 D:\www\TestProject\library\Zend\Controller\Front.php(954): Zend_Controller_Dispatcher_Standard->dispatch(Object(Zend_Controller_Request_Http), Object(Zend_Controller_Response_Http))
#15 D:\www\TestProject\library\Zend\Application\Bootstrap\Bootstrap.php(97): Zend_Controller_Front->dispatch()
#16 D:\www\TestProject\library\Zend\Application.php(366): Zend_Application_Bootstrap_Bootstrap->run()
#17 D:\www\TestProject\public\index.php(26): Zend_Application->run()
#18 {main}
Request Parameters:
array (
'controller' => 'index',
'action' => 'index',
'module' => 'default',
)
I have added the following lines in the php.ini file
我在 php.ini 文件中添加了以下几行
extension=pdo.so
extension=pdo_mysql.so
extension=php_pdo.dll
extension=php_pdo_mssql.dll
Also i have The PDO MySQL packageinstalled in my system. But still I am getting the above exception.... (Also restarted the Apache server)
我也有PDO的MySQL的软件包安装在我的系统。但我仍然收到上述异常......(还重新启动了Apache服务器)
回答by Pascal MARTIN
First of all, you cannot have both :
首先,你不能同时拥有:
extension=pdo.so
extension=pdo_mysql.so
Which are for Linux, and :
哪些适用于 Linux,以及:
extension=php_pdo.dll
extension=php_pdo_mssql.dll
Which are for windows : you've got to choose, depending on the system you are using.
哪些适用于 Windows:您必须根据您使用的系统进行选择。
As you are on windows, you should use the .dllversion.
由于您在 Windows 上,您应该使用该.dll版本。
But note that you used :
但请注意,您使用了:
extension=php_pdo_mssql.dll
i.e. you loaded the pdo_mssqlextension-- which is for Microsoft SQL Server, and not MySQL.
即您加载了pdo_mssql扩展——这是用于 Microsoft SQL Server,而不是 MySQL。
Instead, you should load the extension for MySQL :
相反,您应该加载 MySQL 的扩展:
extension=php_pdo_mysql.dll
After correcting that, restart Apache ; and things should get better.
更正后,重新启动 Apache ;事情应该会好转。
If things don't get better, you should check the output of phpinfo():
如果情况没有好转,您应该检查以下输出phpinfo():
- At the beginning of
phpinfo()'s output, it indicates whichphp.inifile is loaded ; make sure you modified the right one. - Check, lower in the file, if there is a section about
pdo_mysql- If not, check Apache's error_log, just in case ;-)
phpinfo()的输出开头,表示php.ini加载的是哪个文件;确保你修改了正确的。- 检查,在文件下方,是否有关于
pdo_mysql- 如果没有,请检查 Apache 的 error_log,以防万一;-)
回答by clyfe
Mabe swich backed from PDO to Mysqli helps, they're swichable in ZF (i did so).
从 PDO 支持到 Mysqli 的 Mabe 切换有帮助,它们可以在 ZF 中切换(我这样做了)。
回答by Jude
Today I have moved one website from our testing server to the client server and getting such kind of the error that The PDO extension is required for this adapter but the extension is not loaded. I was thinking that there must be pdo.so php extension which is not installed on the server. After recogniging the problem, I was looking for the php.ini file to check the extension but due to the shared hosting they did not provide me the ini file.
今天,我将一个网站从我们的测试服务器移到了客户端服务器,并收到了这样的错误:该适配器需要 PDO 扩展,但未加载该扩展。我在想一定有 pdo.so php 扩展没有安装在服务器上。认识到问题后,我正在寻找 php.ini 文件来检查扩展名,但由于共享主机,他们没有向我提供 ini 文件。
Here in this post I am trying to describe how to solve the such kind of the problem it is very easy and you can solve the problem by using the steps given below:
在这篇文章中,我试图描述如何解决此类问题,它非常简单,您可以使用以下步骤解决问题:
If you want to know more regarding the PDO look at http://php.net/manual/en/ref.pdo-mysql.php
如果您想了解有关 PDO 的更多信息,请查看http://php.net/manual/en/ref.pdo-mysql.php
If you have access of the php.ini file then check
如果您有权访问 php.ini 文件,请检查
;extension=pdo_mysql.so
Just you need to uncomment the line to activate so it looks like as
只是您需要取消注释要激活的行,因此它看起来像
extension=pdo_mysql.so
Save the file and restart the server.
保存文件并重新启动服务器。
If you have no access of the php.ini file, follow the following steps
如果没有权限访问 php.ini 文件,请按照以下步骤操作
Step 1. Please check your Magento installation directory there must me a file named as php.ini.sample.
步骤 1. 请检查您的 Magento 安装目录,那里必须有一个名为 php.ini.sample 的文件。
Step 2. Now rename the file from php.ini.sample to php.ini
步骤 2. 现在将文件从 php.ini.sample 重命名为 php.ini
Step 3. Put the below code into it
步骤 3. 将以下代码放入其中
extension = pdo.so
extension = pdo_sqlite.so
extension = sqlite.so
extension = pdo_mysql.so
Step 4. Now refresh your browser cache and the problem has been solved.
第 4 步。 现在刷新浏览器缓存,问题已解决。
回答by Ilian
If your on godaddy hosting account and you can't do anything because of the restriction to main configuration files of the server and you cant restart apache. You can bypass this problem by changing the php version from "Select PHP Version" this way you will restart settings. In my case I tryied to edit php.ini than php5.ini also added .user.ini file and in result of that i got this error: PDO extension is required for this adapter but the extension is not loaded Now my problem is solved, this solution can work on other hostings not only godaddy if you are not a system administrator!!!
如果您在godaddy托管帐户上,由于服务器主要配置文件的限制而无法执行任何操作,并且无法重新启动apache。您可以通过从“选择 PHP 版本”更改 php 版本来绕过此问题,这样您将重新启动设置。在我的情况下,我尝试编辑 php.ini 而不是 php5.ini 还添加了 .user.ini 文件,结果我收到了这个错误:这个适配器需要 PDO 扩展,但没有加载扩展 现在我的问题解决了,如果您不是系统管理员,此解决方案不仅可以在 Godaddy 上适用于其他主机!!!

