PDOException “could not find driver” in php

后端 未结 8 765
误落风尘
误落风尘 2020-12-03 21:11

I have installed Lampp on my linux system, and I am learning symfony2, while trying to create the schema with symfony2 command

php app/console doctrine:sche         


        
相关标签:
8条回答
  • 2020-12-03 21:40

    You need to have a module called pdo_mysql.

    Look for the following in phpinfo() output,

    pdo_mysql => PDO Driver for MySQL, client library version => 5.1.44

    to install pdo_mysql you need to do this:

     pecl install pdo
     pecl install pdo_mysql
    

    and then add the following to your php.ini file:

    extension=pdo.so
    extension=pdo_mysql.so
    
    0 讨论(0)
  • 2020-12-03 21:41

    In Ubuntu, write in the console

    sudo apt-get install php5-gd php5-mysql
    

    and it will work

    0 讨论(0)
  • 2020-12-03 21:47

    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.

    If you didn't go through a package manager, then you'll have to compile the required .so files from source.

    0 讨论(0)
  • 2020-12-03 21:57

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

    When I run the command php app/console doctrine:schema:update I have the error : [PDOException] could not find driver

    I resolve this error by specifying the PHP version:

    php5.6 app/console doctrine:schema:update
    
    0 讨论(0)
  • 2020-12-03 21:57

    if you are using XAMPP then in php.ini file line no 897(depends on version),

    ;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.

    0 讨论(0)
  • 2020-12-03 22:00

    I had the same problem and for me, it was having multiple PHP versions. So specifying the full address of the PHP solved the problem.

    0 讨论(0)
提交回复
热议问题