PHP - 如何安装 PDO 驱动程序?(视窗)
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/25948767/
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
PHP - How to install PDO driver? (Windows)
提问by Artem
I am setting up PHP and MySQL (Maria DB) on Windows 8.1. I edited php.ini file and uncommented the following lines:
我正在 Windows 8.1 上设置 PHP 和 MySQL (Maria DB)。我编辑了 php.ini 文件并取消了以下几行的注释:
extension=php_mysql.dll
extension=php_mysqli.dll
extension=php_pdo_mysql.dll
But unfortunately I cannot connect to database because there are no pdo drivers shown in phpinfo output. So, when I try to establish database connection, an exception is thrown:
但不幸的是,我无法连接到数据库,因为 phpinfo 输出中没有显示 pdo 驱动程序。所以,当我尝试建立数据库连接时,抛出异常:
Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'
How can this problem be solved?
如何解决这个问题?
回答by Artem
Finaly I managed to settle this stuff. I corrected extension_dir entry (absolute file path was needed) in php.ini file and database connection began to work.
最后我设法解决了这个问题。我更正了 php.ini 文件中的 extension_dir 条目(需要绝对文件路径),数据库连接开始工作。
回答by Stark182
Check the extension_dir of your current apache directory, i installed 2 php versions and apache, and the problem was in wamp\bin\apache\Apache2.4.23\bin\php.ini , the path of ext was incorrect
查看你当前apache目录的extension_dir,我安装了2个php版本和apache,问题出在wamp\bin\apache\Apache2.4.23\bin\php.ini,ext路径不对