PHP PDO异常:找不到驱动程序

时间:2023-01-26 13:00:55

Does the MySQL-server and PHP5-MySQLi version have to match in order for a connection to be possible? I'm currently receiving the error below: I am running BSD."Fatal error: Uncaught exception 'PDOException' with message 'could not find driver'..."

MySQL服务器和PHP5-MySQLi版本是否必须匹配才能实现连接?我目前收到以下错误:我正在运行BSD。“致命错误:未捕获异常'PDOException',消息'找不到驱动程序'......”

Here is the the connection info:

这是连接信息:

$info = "mysql:dbname=myDB;host=localhost";$user = "dbUser";$pw = "somePW";return(new PDO($info, $user, $pw));

Here is my MySQL information:

这是我的MySQL信息:

mysql-server-5.5.24

php5-mysqli-5.4.3

3 个解决方案

#1


3  

PDO uses database specific drivers to connect to database systems. It looks like you are missing the pdo_mysql driver that is required to connect to a MySQL database. There is some details on installing the driver on the pdo_mysql manual page, or there may be a BSD package that you can use (I am afraid I'm not familiar enough with BSD to offer specific advice).

PDO使用特定于数据库的驱动程序连接到数据库系统。看起来您缺少连接到MySQL数据库所需的pdo_mysql驱动程序。有关在pdo_mysql手册页上安装驱动程序的一些细节,或者可能有一个可以使用的BSD软件包(恐怕我对BSD不够熟悉,无法提供具体的建议)。

#2


16  

I had this same issue on my CentOS install. I had tried to install imagick and hosed my install. When I removed all of my php files and reinstalled something wasn't working right.

我在CentOS安装上遇到了同样的问题。我曾尝试安装imagick并安装了我的安装程序。当我删除所有我的PHP文件并重新安装的东西不能正常工作。

I ran:

yum install php-pdoyum install php-pdo_mysql

After doing those two lines I ran

在做完这两行后,我跑了

service httpd restart

and everything came back up and running.

一切都恢复正常。

#3


2  

Thanks to zerkms and John C for pointing me in the right direction. Below are the commands I used to install the driver:

感谢zerkms和John C指出我正确的方向。以下是我用来安装驱动程序的命令:

#cd /usr/ports/databases/php5-pdo_mysql#make install clean#apachectl restart

#1


3  

PDO uses database specific drivers to connect to database systems. It looks like you are missing the pdo_mysql driver that is required to connect to a MySQL database. There is some details on installing the driver on the pdo_mysql manual page, or there may be a BSD package that you can use (I am afraid I'm not familiar enough with BSD to offer specific advice).

PDO使用特定于数据库的驱动程序连接到数据库系统。看起来您缺少连接到MySQL数据库所需的pdo_mysql驱动程序。有关在pdo_mysql手册页上安装驱动程序的一些细节,或者可能有一个可以使用的BSD软件包(恐怕我对BSD不够熟悉,无法提供具体的建议)。

#2


16  

I had this same issue on my CentOS install. I had tried to install imagick and hosed my install. When I removed all of my php files and reinstalled something wasn't working right.

我在CentOS安装上遇到了同样的问题。我曾尝试安装imagick并安装了我的安装程序。当我删除所有我的PHP文件并重新安装的东西不能正常工作。

I ran:

yum install php-pdoyum install php-pdo_mysql

After doing those two lines I ran

在做完这两行后,我跑了

service httpd restart

and everything came back up and running.

一切都恢复正常。

#3


2  

Thanks to zerkms and John C for pointing me in the right direction. Below are the commands I used to install the driver:

感谢zerkms和John C指出我正确的方向。以下是我用来安装驱动程序的命令:

#cd /usr/ports/databases/php5-pdo_mysql#make install clean#apachectl restart