[php] Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL

I'm trying to connect with PostgreSQL database through Laravel in order to do a php artisan migrate but doesn't seem to be directed since it's reading the database name of MySQL.

Here are the commands from database.php:

'connections' => array(

    'sqlite' => array(
        'driver'   => 'sqlite',
        'database' => __DIR__.'/../database/production.sqlite',
        'prefix'   => '',
    ),

    'mysql' => array(
        'driver'    => 'mysql',
        'host'      => 'localhost',
        'database'  => 'database',
        'username'  => 'root',
        'password'  => '',
        'charset'   => 'utf8',
        'collation' => 'utf8_unicode_ci',
        'prefix'    => '',
    ),

    'pgsql' => array(
        'driver'   => 'pgsql',
        'host'     => 'localhost',
        'database' => 'postgres',
        'username' => 'postgres',
        'password' => 'root',
        'charset'  => 'utf8',
        'prefix'   => '',
        'schema'   => 'public',
    ),

    'sqlsrv' => array(
        'driver'   => 'sqlsrv',
        'host'     => 'localhost',
        'database' => 'database',
        'username' => 'root',
        'password' => '',
        'prefix'   => '',
    ),

),

If I remove the MySQL paths I'll get:

[InvalidArgumentException]
Database [mysql] not configured.


EDIT: When trying to do php artisan migrate I get a 'PDOException: could not find driver'. I'm using WAMP and I'm in Win8.1. Using PostgreSQL as database.


EDIT: Have experimented a series of alternative solutions but I'm still ought to get this solved. The php.ini file was checked in Apache, WAMP (from php folder) and PostgreSQL. The extension_dir is correct as it being -> extension_dir = "c:/wamp/bin/php/php5.5.12/ext/"

The extension=pdo_pgsql.dll and extension=pgsql.dll are uncommented.

Done the PATH trick in the 'System Variables' and rebooted. No chance.

Thanks for the help so far.

These are my drivers php_pdo_driver.h & php_pdo.h from C:\Program Files (x86)\PostgreSQL\EnterpriseDB-ApachePHP\php\SDK\include\ext\pdo

Information from phpinfo:

PHP Version 5.5.12

Compiler MSVC11 (Visual C++ 2012) Configure Command cscript /nologo configure.js "--enable-snapshot-build" "--disable-isapi" "--enable-debug-pack" "--without-mssql" "--without-pdo-mssql" "--without-pi3web" "--with-pdo-oci=C:\php-sdk\oracle\x64\instantclient10\sdk,shared" "--with-oci8=C:\php-sdk\oracle\x64\instantclient10\sdk,shared" "--with-oci8-11g=C:\php-sdk\oracle\x64\instantclient11\sdk,shared" "--enable-object-out-dir=../obj/" "--enable-com-dotnet=shared" "--with-mcrypt=static" "--disable-static-analyze" "--with-pgo"

This question is related to php database postgresql laravel syntax-error

The answer is


For PHP 7 in Ubuntu you can also do:

sudo apt-get install php7.0-pgsql

So, now you can do not uncomment lines in php.ini

UPD: I have a same error, so problem was not in driver. I changed my database.ini, but every time I saw an error. And I change database config in .env and errors gone.


I had the same error on PHP 7.3.7 docker with laravel:

This works for me

apt-get update && apt-get install -y libpq-dev && docker-php-ext-install pdo pgsql pdo_pgsql

This will install the pgsql and pdo_pgsql drivers.

Now run this command to uncomment the lines extension=pdo_pgsql.so and extension=pgsql.so from php.ini

sed -ri -e 's!;extension=pdo_pgsql!extension=pdo_pgsql!' $PHP_INI_DIR/php.ini

sed -ri -e 's!;extension=pgsql!extension=pgsql!' $PHP_INI_DIR/php.ini

You should remove the comment before extension on your driver.

The driver came disactivated by default you should active by yourself. after that it will work well.

I hope this do.


For PDOException: could not find driver for MySQL, and if it is Debian based OS,

sudo apt-get -y install php5-mysql

I had the same issue. This is what worked for me.

There are 2 php.ini files:

  • C:\wamp\bin\apache\apache2.4.9\bin
  • C:\wamp\bin\php\php5.5.12

NOTE: This is using my version of PHP and Apache, change to what yours are.

The php.ini file located in the both folders is what you need to update, the extentions:

  • extension=php_pdo_pgsql.dll
  • extension=php_pgsql.dll

These are what you need to uncomment (remove the ; symbol).

Restart both Wamp and the Command Prompt.

Hopefully it will work for you :).


Old thread I know, but I lost a couple of hours of my life with this. You also need to set the DB info in the .env file. You don't have to specify the driver here because the default specified in database.php is used (I think). I was struggling because it had DB_CONNECTION=mysql in the .env file and I was using pgsql.


Using Laravel V 5.5.39 with Php 7.1.12 is working fine, but later (newer) php versions cause the problem. So, change Php version and you will get the solution 100% .


I see you are using Windows. I was not able to fix this with enabling any of the extensions that come with my Windows WAMP Server. I tried PDO_ODBC and others and even found the Microsoft Official PDO_SQLSRV.

The solution for me was to install the PDO_SQLSRV drivers from a 3rd party website. I found the drivers through http://robsphp.blogspot.nl/2012/06/unofficial-microsoft-sql-server-driver.html

I usually don't use DLLs from random websites, but I was desperate and this worked for me. Hoping it might save others numerous hours of frustration.


In Linux(Ubuntu) just install the driver like so:

sudo apt-get install php-pgsql

This will install the driver with using your php current version.


Solved after 3 hours... I am using WAMP (PHP 7.2.4), PostgreSQL 10, Laravel 5.6.29. Loaded PHP extensions (pgsql, pdo_pgsql) from Wampserver 3.3, then I was able to connect to the PostgreSQL server with a simple php testcode from the www directory. But $ php artisan migrate still returned

PDOException::("could not find driver")

I checked the shell (git bash for windows) with $ php --ini, that returned C:\wamp64\bin\php\php7.2.4\php.ini instead of c:\wamp64\bin\apache\apache2.4.33\bin\php.ini, loaded by WAMP So you have to uncomment pgsql and pdo_pgsql extensions also in C:\wamp64\bin\php\php7.2.4\php.ini, and then migrate will work ...


Just run this command

sudo apt-get -y install php*-mysql

In Windows 8 PC with Laragon 3.4.0 180809, I faced the same issue. It happened in my case because I updated Laragon and it added a new version of PHP. So in laragon/bin/php/ I actually had two directories:

  • php-7.1.20-Win32-VC14-x64
  • php-7.1.7-Win32-VC14-x64

I added 7.1.20 into my PATH variable. But in my Command Console, running php --ini was showing that the path actually was fetching from the older one: php-7.1.7-Win32-VC14-x64. So I deleted the old one (for safety, I put it in Recycle Bin). But Laragon failed to start after that.

So, in laragaon/etc/apache2/mod_php.conf, I changed the path to the latest PHP version. Then restarted Laragon and the issue is resolved.

Reference: How to add another PHP version - Laragon Forum


For those wanting to use Postgresql on OpenSuse (and co), try the following:

zypper --no-refresh in php5-pgsql

sudo apt-get install php7.1-pgsql

This worked for me:

$ sudo apt-get -y install php5.6-pgsql
$ sudo service apache2 restart

I am working with 32bit Ubuntu 14


I realize this is an old question but I found it in a Google search so I'm going to go ahead and answer just in case someone else runs across this. I'm on a Mac and had the same issue, but solved it by using HomeBrew. Once you've got it installed, you can just run this command:

brew install php56-pdo-pgsql

And replace the 56 with whatever version of PHP you're using without the decimal point.


I got this problem too. I have solved this issue already. If u are using Wamp then perform the following steps.

  1. Go to wamp64/www/bin/php/php* (where * is the php version you are using)
  2. Edit file php and uncomment this line by removing the semicolon:
;extension=pdo_pgsql to extension=pdo_pgsql
  1. Save and restart your Wamp server

If it does not work, please check your .env and config/database again.


This worked for me:

$ sudo apt-get install php-gd php-mysql

Examples related to php

I am receiving warning in Facebook Application using PHP SDK Pass PDO prepared statement to variables Parse error: syntax error, unexpected [ Preg_match backtrack error Removing "http://" from a string How do I hide the PHP explode delimiter from submitted form results? Problems with installation of Google App Engine SDK for php in OS X Laravel 4 with Sentry 2 add user to a group on Registration php & mysql query not echoing in html with tags? How do I show a message in the foreach loop?

Examples related to database

Implement specialization in ER diagram phpMyAdmin - Error > Incorrect format parameter? Authentication plugin 'caching_sha2_password' cannot be loaded Room - Schema export directory is not provided to the annotation processor so we cannot export the schema SQL Query Where Date = Today Minus 7 Days MySQL Error: : 'Access denied for user 'root'@'localhost' SQL Server date format yyyymmdd How to create a foreign key in phpmyadmin WooCommerce: Finding the products in database TypeError: tuple indices must be integers, not str

Examples related to postgresql

Subtracting 1 day from a timestamp date pgadmin4 : postgresql application server could not be contacted. Psql could not connect to server: No such file or directory, 5432 error? How to persist data in a dockerized postgres database using volumes input file appears to be a text format dump. Please use psql Postgres: check if array field contains value? Add timestamp column with default NOW() for new rows only Can't connect to Postgresql on port 5432 How to insert current datetime in postgresql insert query Connecting to Postgresql in a docker container from outside

Examples related to laravel

Parameter binding on left joins with array in Laravel Query Builder Laravel 4 with Sentry 2 add user to a group on Registration Target class controller does not exist - Laravel 8 Visual Studio Code PHP Intelephense Keep Showing Not Necessary Error The POST method is not supported for this route. Supported methods: GET, HEAD. Laravel How to fix 'Unchecked runtime.lastError: The message port closed before a response was received' chrome issue? Post request in Laravel - Error - 419 Sorry, your session/ 419 your page has expired Expected response code 250 but got code "530", with message "530 5.7.1 Authentication required How can I run specific migration in laravel Laravel 5 show ErrorException file_put_contents failed to open stream: No such file or directory

Examples related to syntax-error

Uncaught SyntaxError: Unexpected token u in JSON at position 0 How to solve SyntaxError on autogenerated manage.py? Checking whether the pip is installed? (unicode error) 'unicodeescape' codec can't decode bytes in position 2-3: truncated \UXXXXXXXX escape How can you print multiple variables inside a string using printf? Unexpected token < in first line of HTML Laravel: Error [PDOException]: Could not Find Driver in PostgreSQL 'Syntax Error: invalid syntax' for no apparent reason How can I fix MySQL error #1064? Notice: Trying to get property of non-object error