6

Hello i'm trying to connect laravel 5.4 with postgres, after updating the database configuration file and running php artisan migrate, the following error appears:

[Illuminate\Database\QueryException]
 could not find driver (SQL: select * from information_schema.tables where t
 able_schema = public and table_name = migrations)
[PDOException]
 could not find driver

this is my .env file

DB_CONNECTION=pgsql
DB_HOST=127.0.0.1
DB_PORT=5432
DB_DATABASE=Portail
DB_USERNAME=php
DB_PASSWORD=php

and this is my database.php file

'default' => env('DB_CONNECTION', 'pgsql'),
 'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            'database' => env('DB_DATABASE', 'Portail'),
            'username' => env('DB_USERNAME', 'php'),
            'password' => env('DB_PASSWORD', 'php'),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer', ], 

and i use phpPgAdmin normally

8
  • Try to set DB_HOST = localhost instead of 127.0.0.1 Commented Apr 26, 2017 at 14:45
  • do not work too Commented Apr 26, 2017 at 14:52
  • You probably do not have PHP module pgsql installed. Commented Apr 26, 2017 at 14:53
  • i use phpPgAdmin normally with php_pgsql Commented Apr 26, 2017 at 14:54
  • i use wampserver 3.0.6 64 bit and php 7 Commented Apr 26, 2017 at 14:56

4 Answers 4

13

sudo apt-get install php-pgsql. This is the command to install php pgsql driver in linux

Sign up to request clarification or add additional context in comments.

2 Comments

i use windows and my php_pgsql work i connect php with phppgadmin without laravel but with laravel don't work
That fixed my problem. I was trying php artisan migrate and got the error: “could not find driver (SQL: select * from information_schema.tables where table_schema = laravel and table_name = migrations and table_type = 'BASE TABLE')” Installing the driver to Ubuntu 20 fixed the problem. Thanks @JohnSimon
4

I had a similar problem using on Ubuntu18.04 using php7.4 Solution:

  • First check you PHP version with php -v, in my case the version come out to be php7.4 so installed the necessary driver with apt-get install php7.4-pgsql

  • Finally restart the PHP server

Comments

2

I found the solution there are two php.ini files

  • C:\wamp64\bin\apache\apache2.4.9\bin

  • C:\wamp64\bin\php\php7.0.10

i must do uncommented php_pdo_pgsql.dll and php_pgsql.dll in the two files thanks for your help all

1 Comment

For those using XAMPP, Navigate to C:\xampp\php folder and open the php.ini file and Then enable the pdo_pgsql and pgsql extensions by removing the preceding ; (semicolon) on these lines; extension=pdo_pgsql extension=pgsql For more details, visit neutrondev.com/setup-postgresql-in-xampp-for-windows
1

For those using XAMPP, Navigate to C:\xampp\php folder and open the php.ini file and Then enable the pdo_pgsql and pgsql extensions by removing the preceding ; (semicolon) on these lines; extension=pdo_pgsql extension=pgsql For more details, visit https://neutrondev.com/setup-postgresql-in-xampp-for-windows/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.