1

I deploy a laravel project on an apache server on a Debian 10 machine. The database is an MySQL deployed on another debian 10 machine on the same network.

I can go to the connection interface of the application but when I connect this error appears :

Illuminate\Database\QueryException
could not find driver (SQL: select * from `users` where `email` = test@gmail.com limit 1)

I have already tried these commands :

php artisan migrate
sudo apt install php-mysql
sudo apt install php7.4-mysql
sudo systemctl restart apache2
composer require doctrine/dbal
composer update

these commands work but do not solve the problem.

and I already tried to comment and uncomment this line in the php.ini :

extension=pdo_mysql

in php-m i have PDO and pdo-mysql

and i have restart my server with :

systemctl restart apache2

after modification

  • If you run php -m from the command line, does it list pdo? If yes – Abu Sayem Jun 09 '22 at 05:56
  • have you restarted your php server after comment and UN-comment – Aqib Javed Jun 09 '22 at 06:18
  • also be sure to both run php artisan -vvv to get more verbose output and check your configured logfile, default storage/log/laravel.log to get more info, there is probably a stack trace that tell more precisley what the error is – Patrik Grinsvall Jun 11 '22 at 10:01
  • Does this answer your question? [Illuminate\Database\QueryException : could not find driver](https://stackoverflow.com/questions/57547651/illuminate-database-queryexception-could-not-find-driver) – Elias Soares May 13 '23 at 01:31

4 Answers4

0

I got the same error when running my test suite. It was working before but it stopped working after I upgraded php. So I did and it worked for me.

sudo apt-get install php-sqlite3
0

If you have no problem using php artisan migrate, there is no problem for the command line to call the php script. If you use fpm and install a new extension, you need to restart it and try.

Gavin Lee
  • 1
  • 1
0

I finally found the solution infact the php version used by apache was 7.3 and not 7.4 with :

<?php phpinfo() ?>

however when I did:

php --version

the version was indeed 7.4. I followed this tutorial to change the version https://tecadmin.net/switch-between-multiple-php-version-on-debian/?amp and it works

0

I got this same error while running Laravel in a docker container. In my case the issue was that I did not install PDO when building the image. I solved this by adding the following line to my Dockerfile:

RUN docker-php-ext-install pdo pdo_mysql
Adam Winter
  • 1,680
  • 1
  • 12
  • 26