Laravel 8 - Could not find driver : Illuminate\Database\QueryException could not find driver (SQL: select * from `list`)

Laravel 8 - Could not find driver : Illuminate\Database\QueryException could not find driver (SQL: select * from `list`)

  1. Blog
  2. 15 November 2026
  3. 3 min read

Stefan Bogdanescu

Founder & Senior Architect

Resolving the "Could Not Find Driver" Error in Laravel 8

When migrating from a local XAMPP environment to a production-like setup or simply moving between operating systems, one of the most frustrating runtime errors is Illuminate\Database\QueryException: could not find driver. This specific exception often strikes developers who have successfully configured their .env file and verified their database tables, yet Laravel still refuses to execute a simple SELECT query.

The core issue here is rarely your application logic or your route definitions. In the scenario described, the user has correctly set up DB_CONNECTION=mysql in the .env file and confirmed the list table exists within the MySQL instance running on XAMPP. The error persists because Laravel's PHP runtime cannot locate the specific PDO driver extension required to communicate with MySQL.

Understanding the Driver Mismatch

Laravel relies on PHP's PDO (PHP Data Objects) interface to interact with databases. For MySQL connections, this requires the pdo_mysql extension to be loaded in your PHP environment. While XAMPP typically bundles these extensions automatically, switching operating systems—such as moving from Windows to Linux Mint 20—changes the landscape entirely.

Linux distributions often do not come with the specific database drivers pre-installed or compiled into the default PHP version. Even if you are using the same PHP version installed by XAMPP (e.g., via a Docker container or a manual installation), the underlying system libraries might differ, causing the extension to be missing or unloaded.

Diagnosing the Missing Extension

Before attempting to install packages, you must verify whether the extension is actually available to the PHP process running your Laravel application. Execute the following command in your terminal:

php -m | grep pdo_mysql

If this command returns nothing, the pdo_mysql extension is not loaded. If it does appear, check for potential conflicts or if the configuration file is being ignored by the specific PHP-FPM pool Laravel uses.

Installing the Required Dependencies

On Linux Mint 20, which typically ships with PHP 8.x (or a version close to it), you need to ensure the appropriate packages are installed and enabled. The standard procedure involves updating your package manager and installing the necessary development libraries:

sudo apt update
sudo apt install php-mysql php-pgsql php-sqlite3 libpq-dev

After installation, restart the PHP-FPM service or your web server (Apache/Nginx) to load the new extensions:

sudo systemctl restart php8.1-fpm
# Or sudo systemctl restart apache2 / nginx

Note: The exact version number (e.g., php8.1) will depend on what is installed on your specific system.

Verifying Configuration Changes

Once the packages are installed, you must ensure they are active. Check the loaded modules again:

php -m | grep pdo_mysql

You should see pdo_mysql listed in the output. If the list remains empty despite installation, inspect your PHP configuration. The extension might be commented out in /etc/php/8.1/mods-available/pdo_mysql.ini. Uncomment the line extension=pdo_mysql to activate it.

The XAMPP vs. System PHP Caveat

A common pitfall for beginners is assuming that because a command works on one machine, it will work identically on another without checking the underlying environment. In your case, you are likely running Laravel via a system-installed PHP (common in Linux Mint) rather than the bundled XAMPP PHP found on Windows. These two environments have distinct paths and configurations.

Your controller logic:

public function tabel()
{
    $tabelku = DB::table('list')->get();
    return view('tabel', ['people' => $tabelku]);
}

and your route definition are syntactically correct. The application code assumes the database connection is available, but PHP cannot bridge that gap without the extension.

Final Validation

After restarting your web server, refresh your browser at localhost:8000/home/tabel. The QueryException should be resolved, and you will see the rendered table displaying the data from your list table. If issues persist, ensure that your .env file permissions are set correctly (chmod 644 .env) so Laravel can read the configuration without throwing permission errors.

For further reading on managing database connections in modern PHP environments, developers often refer to resources like https://laravelcompany.com for detailed guides on architecture and deployment strategies.

Our network