Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

vandan's avatar
Level 13

Illuminate\Database\QueryException : could not find driver

hello everyone i need some help when i try to php artisan migrate then error like at /opt/lampp/htdocs/blo3/vendor/laravel/framework/src/Illuminate/Database/Connection.php: 664 660: // If an exception occurs when attempting to run a query, we'll format the error 661: // message to include the bindings with SQL, which will make this exception a 662: // lot more helpful to the developer instead of just the database's errors. 663: catch (Exception $e) { 664: throw new QueryException( 665: $query, $this->prepareBindings($bindings), $e 666: ); 667: } 668: 669: return $result;

Exception trace:

1 Doctrine\DBAL\Driver\PDOException::("could not find driver") /opt/lampp/htdocs/blo3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php : 31

2 PDOException::("could not find driver") /opt/lampp/htdocs/blo3/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/PDOConnection.php : 27

Illuminate\Database\QueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = blog and table_name = migrations)

0 likes
27 replies
Nakov's avatar

If you can, run :

composer update

composer require doctrine/dbal

You might also need to uncomment the following in your php.ini file.

;extension=pdo_mysql.so

Remove the ; to uncomment.

6 likes
Tapo2003's avatar

@Nakov this is what is showing

Loading composer repositories with package information Updating dependencies Your requirements could not be resolved to an installable set of packages.

Problem 1 - laravel/framework[v9.36.4, ..., v9.52.16] require league/flysystem ^3.8.0 -> satisfiable by league/flysystem[3.8.0, ..., 3.28.0]. - laravel/framework[v9.19.0, ..., v9.36.3] require league/flysystem ^3.0.16 -> satisfiable by league/flysystem[3.0.16, ..., 3.28.0]. - league/flysystem[3.0.10, ..., 3.14.0] require league/mime-type-detection ^1.0.0 -> satisfiable by league/mime-type-detection[1.0.0, ..., 1.15.0]. - league/flysystem[3.15.0, ..., 3.28.0] require league/flysystem-local ^3.0.0 -> satisfiable by league/flysystem-local[3.15.0, ..., 3.28.0]. - league/mime-type-detection[1.0.0, ..., 1.3.0] require php ^7.2 -> your php version (8.3.10) does not satisfy that requirement. - league/mime-type-detection[1.4.0, ..., 1.15.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. - league/flysystem-local[3.15.0, ..., 3.28.0] require ext-fileinfo * -> it is missing from your system. Install or enable PHP's fileinfo extension. - Root composer.json requires laravel/framework ^9.19 -> satisfiable by laravel/framework[v9.19.0, ..., v9.52.16].

To enable extensions, verify that they are enabled in your .ini files: - C:\Program Files\php-8.3.10\php.ini You can also run php --ini in a terminal to see which files are used by PHP in CLI mode. Alternatively, you can run Composer with --ignore-platform-req=ext-fileinfo to temporarily ignore these required extensions.

Use the option --with-all-dependencies (-W) to allow upgrades, downgrades and removals for packages currently locked to specific versions.

vandan's avatar
Level 13

i done already but phase same error nothing work

1 like
munazzil's avatar

Maybe cache problem clear cache,

    php artisan cache:clear
    php artisan view:clear
    php artisan route:clear

and also check your .env file,

  DB_CONNECTION=mysql
  DB_HOST=127.0.0.1
  DB_PORT=3306
  DB_DATABASE=dbname
  DB_USERNAME=root
  DB_PASSWORD=secret
5 likes
Tapo2003's avatar

@munazzil . Hi, are you available to help ? Still facing the issue . Or is anyone available ?

Sinnbeck's avatar

If you run php -m from the command line, does it list pdo?

2 likes
sevenTopo's avatar

No i cant find PDO in the list ? what shoud i do now ?

gildniy's avatar

If you are using NGINX; you need to:

  • Make sure to have run apt-get install php5.6-mysql/php7.2-mysql
  • Activate the pdo extension (Uncommenting ;extension=pdo_mysql in the php.ini (sudo nano /etc/php/7.2/cli/php.ini)
  • Restart the server service nginx restart
4 likes
lara177438's avatar

Or while installing php add php-pgsql

sudo apt install php-fpm php-pgsql
1 like
IO_Digital's avatar

Hey there i know its a lil late buh i had the same problem yesterday and Alhamdulilah managed to fix it

you do the following (and this is for ubuntu and nginx , check syntax for apache etc)

sudo apt-get install php-mysql (just to make sure you have it) then

sudo phpenmod pdo_mysql (this enables the pdo_mysql module which is the driver actually)

sudo service nginx restart

sudo service php7.4-fpm restart (based on the fpm version you running)

and it should be good to go inshallah

5 likes
armancs's avatar

I have faced the same problem in my ubuntu os you have to install php mysql driver to run this please run below command and start xampp / lampp again and serve your artisan command

sudo apt install php-mysql
3 likes
xingredient's avatar

I was using an Sqlite database.

Might be good to notice that for an sqlite database you need to uncomment "extension=pdo_sqlite" as well

SG-Philipp's avatar

I have multiple php versions installed and switch between them. That's why I also did run into this error. Setting back to version php8.1 from php8.0 fixed the issue. In case someone else runs into this

Ahla's avatar

check that the DB Port on the .env file is the same as the port of the database.

Abiodun_Sam's avatar

I just ran

composer update

and the problem was solved.

duanlaravel's avatar

The problem was not resolved. the same issue repeats.

Please or to participate in this conversation.