PDOException“无法在php中找到驱动程序”

时间:2022-09-19 14:46:19

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

我还在php.ini文件中取消注释此行extension = php_pdo_mysql.dll

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 ?

有没有办法可以解决这个问题?

7 个解决方案

#1


7  

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.

希望您在localhost中运行您的项目。在项目文件夹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.

希望它能帮到你。

#2


7  

In Ubuntu, write in the console

在Ubuntu中,写入控制台

sudo apt-get install php5-gd php5-mysql

and it will work

它会起作用

#3


5  

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

#4


1  

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安装php70-pdo-pgsql以防你在mac上使用brew安装php7,并根据你安装的内容更改php版本。

#5


0  

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文件。

#6


0  

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。

#7


0  

There are two PHP versions installed in my server PHP 5.6 and PHP 7

我的服务器PHP 5.6和PHP 7中安装了两个PHP版本

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]找不到驱动程序

I resolve this error by specifying the PHP version:

我通过指定PHP版本来解决此错误:

php5.6 app/console doctrine:schema:update

#1


7  

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.

希望您在localhost中运行您的项目。在项目文件夹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.

希望它能帮到你。

#2


7  

In Ubuntu, write in the console

在Ubuntu中,写入控制台

sudo apt-get install php5-gd php5-mysql

and it will work

它会起作用

#3


5  

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

#4


1  

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安装php70-pdo-pgsql以防你在mac上使用brew安装php7,并根据你安装的内容更改php版本。

#5


0  

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文件。

#6


0  

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。

#7


0  

There are two PHP versions installed in my server PHP 5.6 and PHP 7

我的服务器PHP 5.6和PHP 7中安装了两个PHP版本

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]找不到驱动程序

I resolve this error by specifying the PHP version:

我通过指定PHP版本来解决此错误:

php5.6 app/console doctrine:schema:update