elemkeh's avatar

PDO Exception: Could not find driver

Deploying a laravel app using pgsql and now encounter this error when I try to perform php artisan migrate. I have the latest version of php-pgsql installed on the server, and have verified the contents of my .env and database.php, and I uncommented the line containing the pgsql pdo extension in my fpm/php.ini. But after restarting postgresql, I still get this error. Here's the full text:

[Illuminate\Database\QueryException]
could not find driver: (SQL select * from information_schema.tables where tables_schema = username and table_name = migrations)
0 likes
5 replies
SaeedPrez's avatar

Three things come to mind..

  1. Did you also restart the web server (Apache/Nginx)?
  2. Dd you edit the correct php.ini file? You can use phpinfo() to find out.
  3. Did you uncomment the php_pdo_pgsql and not php_pgsql extension?
elemkeh's avatar

@SaeedPrez

  1. Yes.
  2. Is the output of php -i in the command line analogous? Because what I get there in the PDO section is PDO support => enabled and PDO drivers => pgsql, and then in pdo_pgsql, I get
PostgreSQL(libpq) Version =>9.5.4
Module version =>7.0.15-0ubuntu0.16.10.4

and then the revision string. In pgsql I have

PostgreSQL(libpq) Version = 9.5.4
PostgreSQL(libpq) => PostgreSQL 9.5.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu 6.1.1-11ubuntu12) 6.1.1 20160805, 64-bit Multibyte character support => enabled
SSL support => enabled
Active Persistent Links => 0
Active Links => 0
  1. Yes, the uncommented line is php_pdo_pgsql.
SaeedPrez's avatar

I don't know about your setup, a lot of the time there are two different PHP versions on a machine, one for the CLI and one for the web server. Which is why I suggested you do the phpinfo() check..

Did you also search google for laravel ms sql? I found some good info earlier that might help you..

abhisheksubedi's avatar

Your database driver is missing. To solve the probelm

First install the driver

For ubuntu: For mysql database.

sudo apt-get install php5.6-mysql/php7.2-mysql

You also can search for other database systems.

You also can search for the driver:

sudo apt-cache search drivername

Then Run the cmd php artisan migrate

Laravelque's avatar

you are also get error when you are doing composer update right?

this solution work for me, may be it's help you.

go to bootstrap/cache and delete all cache file and then update composer.

after update composer you will run php artisan command also without could not find driver error..

don't worry your cache file generate automatically.

Thanks

Please or to participate in this conversation.