黄聪:PHP数据库连接失败--could not find driver 解决办法

Posted 黄聪

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了黄聪:PHP数据库连接失败--could not find driver 解决办法相关的知识,希望对你有一定的参考价值。

数据库连接失败could not find driver
在调试一个php程序时,报了这个错误, could not find driver
 
经过一番查找,结合自己的思考和实践,终于找到了问题所在.
 
原来我的这个程序中用到了PDO对象, 连接mysql 5. 在PHP的默认设置中,只打开了php_pdo 模块, 没有打开php_pdo_mysql模块.所以才会出现找不到驱动程序的错误.
 
修改php.ini
extension=php_pdo.dll
extension=php_pdo_firebird.dll
extension=php_pdo_mssql.dll
extension=php_pdo_mysql.dll

 
重启apache就可以了. 当然了,如果你用别的数据库,打开对应的模块就OK了.
 
如果在linux下面,确信模块pdo_mysql.so已经编译进php。
 
在php.ini下面添加:
 
extension=pdo_mysql.so

以上是关于黄聪:PHP数据库连接失败--could not find driver 解决办法的主要内容,如果未能解决你的问题,请参考以下文章

php连接数据库提示could not find driver 问题解决

php7连接 sqlserver踩过的坑,could not find driver解决方式

grafana无法连接zabbix Data Sources Could not connect to given url

xshell6 突然连接不上虚拟机,Could not connect to 'xxxx' (port 22): Connection failed.

Oracle报错ORA-12516 TNS:listener could not find available handler with matching protocol stack

flutter踩坑01:下载包失败:Could not resolve all artifacts for configuration....