php php中的PDOException“找不到驱动程序”
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/9308147/
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
PDOException “could not find driver” in php
提问by ScoRpion
I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command
我已经在我的 linux 系统上安装了 Lampp,我正在学习 symfony2,同时尝试使用 symfony2 命令创建模式
php app/console doctrine:schema:create
I am getting the following error message:-
我收到以下错误消息:-
PDOException “could not find driver”
I also uncomment this line extension=php_pdo_mysql.dll
in php.ini file
我也在extension=php_pdo_mysql.dll
php.ini 文件中取消注释这一行
I tried to look and google my issue but couldn't resolve my problem. when i run php -m
command i am getting the following result:-
我试图查看并搜索我的问题,但无法解决我的问题。当我运行php -m
命令时,我得到以下结果:-
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysql.so' - /usr/lib/php5/20090626+lfs/mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/mysqli.so' - /usr/lib/php5/20090626+lfs/mysqli.so: cannot open shared object file: No such file or directory in Unknown on line 0
PHP Warning: PHP Startup: Unable to load dynamic library '/usr/lib/php5/20090626+lfs/pdo_mysql.so' - /usr/lib/php5/20090626+lfs/pdo_mysql.so: cannot open shared object file: No such file or directory in Unknown on line 0
[PHP Modules]
bcmath
bz2
calendar
Core
ctype
date
dba
dom
ereg
exif
fileinfo
filter
ftp
gettext
hash
iconv
json
libxml
mbstring
mhash
openssl
pcntl
pcre
PDO
----
----
Is there a way i can remove this issue ?
有没有办法可以消除这个问题?
采纳答案by Asish AP
Hope you are running your project in localhost. In your project folder app/config a file named parameters.ini , Make sure that your Mysql database connection cofiguration is correct. If you are using mysql See database_driver=pdo_mysql
is its driver.
希望你在本地主机上运行你的项目。在您的项目文件夹 app/config 中,有一个名为 parameters.ini 的文件,确保您的 Mysql 数据库连接配置正确。如果你用的是mysql 看database_driver=pdo_mysql
是它的驱动。
Below is an example.
下面是一个例子。
database_driver = pdo_mysql
database_host = localhost
database_port =
database_name = databasename
database_user = msqlusername
database_password = mysqlpassword//if not make blank
mailer_transport = smtp
mailer_host = localhost
mailer_user =
mailer_password =
locale = en
secret = ThisTokenIsNotSoSecretChangeIt
Hope it helps you.
希望对你有帮助。
回答by ioses
In Ubuntu, write in the console
在 Ubuntu 中,在控制台中写入
sudo apt-get install php5-gd php5-mysql
and it will work
它会起作用
回答by Jaspreet Chahal
You need to have a module called pdo_mysql
.
您需要有一个名为pdo_mysql
.
Look for the following in phpinfo()
output,
在phpinfo()
输出中查找以下内容,
pdo_mysql => PDO Driver for MySQL, client library version => 5.1.44
pdo_mysql => MySQL 的 PDO 驱动程序,客户端库版本 => 5.1.44
to install pdo_mysql you need to do this:
要安装 pdo_mysql,您需要执行以下操作:
pecl install pdo
pecl install pdo_mysql
and then add the following to your php.ini
file:
然后将以下内容添加到您的php.ini
文件中:
extension=pdo.so
extension=pdo_mysql.so
回答by Eralp Karaduman
brew install php70-pdo-pgsql
in case you installed php7 on mac with brew and, change php version according to what you have installed.
brew install php70-pdo-pgsql
如果您使用 brew 在 mac 上安装了 php7,并根据您安装的内容更改 php 版本。
回答by Mohamed Ben HEnda
There are two PHP versions installed in my server PHP 5.6 and PHP 7
我的服务器中安装了两个 PHP 版本 PHP 5.6 和 PHP 7
When I run the command php app/console doctrine:schema:update
I have the error : [PDOException] could not find driver
当我运行命令时php app/console doctrine:schema:update
出现错误:[PDOException] could not find driver
I resolve this error by specifying the PHP version:
我通过指定 PHP 版本来解决此错误:
php5.6 app/console doctrine:schema:update
回答by Mohammad Fareed
if you are using XAMPP then in php.ini file line no 897(depends on version),
如果您使用的是 XAMPP,则在 php.ini 文件第 897 行(取决于版本)中,
;extension=php_pdo_pgsql.dll
uncomment it , then it appears like below
取消注释它,然后它看起来像下面
extension=php_pdo_pgsql.dll
in php.ini file line no 897, then restart XAMPP.
在 php.ini 文件第 897 行中,然后重新启动 XAMPP。
回答by GordonM
Looks like your install is missing the .so files it needs to implement the mysql connection. If you're using a package management system to install PHP then make sure you've installed all the necessary submodules (in this case I think you'll need mysql-dev, and the various PHP PDO modules), though such dependencies should have been resolved for you by the package manager.
看起来您的安装缺少实现 mysql 连接所需的 .so 文件。如果您使用包管理系统来安装 PHP,请确保您已安装所有必要的子模块(在这种情况下,我认为您将需要 mysql-dev 和各种 PHP PDO 模块),尽管此类依赖项应该具有包管理器已为您解决。
If you didn't go through a package manager, then you'll have to compile the required .so files from source.
如果您没有通过包管理器,则必须从源代码编译所需的 .so 文件。