PostgreSql 'PDOException' with message 'could not find driver'

后端 未结 9 1835
悲&欢浪女
悲&欢浪女 2020-12-09 15:30

pdo is working fine with mysql but with pgsql its giving error \'PDOException\' with message \'could not find driver\' I\'ve installed php5-pgsql p

相关标签:
9条回答
  • 2020-12-09 15:50

    Make sure you've uncommented the line that tells php where the Postgres driver is (usually extension=pgsql.so) in the main php.ini file.

    0 讨论(0)
  • 2020-12-09 15:53

    I had the same issue. First of all - check is it enabled in php.ini. Uncomment extension=php_pdo_pgsql...

    than set up extension directory!!

    extension_dir = "ext" ; for your case it could be other dir.
    

    and do not forget to restart server after changing the config.

    0 讨论(0)
  • 2020-12-09 15:54

    Copy libpq.dll from the PHP directory to Apache24\bin (or wherever your installation could be).

    0 讨论(0)
  • 2020-12-09 15:59

    When you do not have postgresql installed on the same machine that is Apache and PHP; you have to install php-pgsql and don't have to add extensions in php.ini manually in Linux (in Windows yes), because redundancies are generated and this does not work (checked in error.log).

    $ sudo apt install php-pgsql
    

    Then you can check the existence of the extension enabled automatically in:

    $ sudo nano /etc/php/7.0/apache2/conf.d/10-pdo.ini
    

    Observations: In phpinfo() you will find the directory conf.d/ and the file error.log

    GL

    0 讨论(0)
  • 2020-12-09 16:01

    This message means you need to install and or activate postgresql extension in PHP

    This solution works for me : To install postgresql extension

    [sudo] apt-get install php-pgsql
    

    after, for activating it, uncomment pgsql and pdo-pgsql extensions in etc/php/$PHP_VERSION/apache2/php.ini file

    Finally, type :

    [sudo] /etc/init.d/apache2 restart
    

    To restart apache server if you use apache such as was my case...

    0 讨论(0)
  • 2020-12-09 16:03

    I had the same problem with another solution. I lost my around 4 hours to solve this problem. Please check the following to solve this problem.

    1. Check php.ini file and remove semicolon from this line

      extension=pgsql

      extension=pdo_pgsql

    2. Restart your apache2 server

      sudo service apache2 restart

    3. Check if your PDO driver has updated in localhost phpinfo()

    I did All the things right and still I had this problem. And you know why? Because I had several versions of php installed. So I was running php7.4 in my php cli but localhost was running on php7.2. So always check your php versions.

    1. Check your php version on localhost and terminal cli

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