If you are working on a Laravel application and encounter this error

could not find driver

Here are a few things you can do to resolve this issue.

If you are working on a fresh Laravel installation, then chances are you might be missing php-mysql extension in your system. Execute the following command on your Linus system to install it

sudo apt-get install php7.3-mysql

Change the php version in the command as per the PHP version you have currently installed in your system.

If you encounter this error while running the phpunit test using sqlite database

Illuminate\Database\QueryException: could not find driver

Then it probably means that you are missing php-sqlite driver from your system. You can fix it by running the following command

sudo apt-get install php7.3-sqlite3

Let me know in comments if the following running the above command fixed the error for you.