Artisan migrate could not find driver

Artisan migrate could not find driver

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

Stefan Bogdanescu

Founder & Senior Architect

Artisan migrate could not find driver

Encountering a could not find driver error when running php artisan migrate is one of the most common stumbling blocks for developers setting up a new Laravel environment. It usually signals a mismatch between the database configuration defined in your .env file or config/database.php and the PHP extensions that are actually installed on your system. In the scenario described, you have XAMPP running with MySQL, yet the migration command fails because PHP cannot locate the specific driver required to communicate with that database engine.

The error message explicitly points to a PDOException. This is not an issue with your database schema or your migration files; it is strictly a PHP runtime problem. When you define a connection in your configuration pointing to MySQL, Laravel attempts to instantiate a PDO (PHP Data Objects) object using the mysql driver. However, if the PHP extension responsible for this communication is missing or disabled, the framework throws this exception immediately upon attempting the first query against the database.

The core issue often stems from how XAMPP handles PHP extensions. Unlike a standard Linux server or a production environment where you manage packages like php-mysql directly via a package manager, XAMPP bundles specific .dll files and configuration settings that must be manually enabled. Simply having MySQL installed in the XAMPP folder is insufficient; the PHP interpreter must know how to talk to it.

To resolve this, you need to ensure that the PDO MySQL extension is active. If you are using a Linux-based environment with XAMPP (or simply managing your own PHP installation), the command line solution is straightforward. You can install the necessary packages using your system's package manager:

sudo apt-get update
sudo apt-get install php-mysql php-pdo
# Or for Debian/Ubuntu older repos:
sudo apt-get install libmysqlclient-dev default-libmysqlclient-dev

For Windows setups like XAMPP, the process requires checking two files in your xampp\php directory: php.ini-development and php.ini-production. You must locate the line reading extension=pdo_mysql.dll (or similar) and ensure it is not commented out with a semicolon. If you are using MySQL 5.7 or later, you might also see references to pdo_mysql.so depending on your PHP version, but the logic remains the same: uncomment the line and restart Apache.

There is another layer of complexity involving the specific database driver versions. While the default configuration in Laravel supports mysql, there are scenarios where developers switch to mysqli or use SQLite for local development. If you choose to switch drivers, you must update both your .env file and your config/database.php accordingly. For instance, changing the driver to sqlite requires a completely different setup path:

'sqlite' => [
    'driver' => 'sqlite',
    'database' => database_path('database.sqlite'),
],

Once you have confirmed that the correct .dll file exists and is loaded in your PHP configuration, you must verify that the extension is actually active. You can do this by creating a new phpinfo() file and searching for "PDO" or "mysqlnd". If these sections are absent, the restart was insufficient, or the wrong architecture DLL was loaded.

It is also worth noting that if you have previously run migrations with a different configuration, Laravel might cache database state. Clearing your application cache using php artisan cache:clear and ensuring your migration table exists (or dropping it manually if it's corrupted) can sometimes help reset the connection state after fixing driver issues.

Ultimately, the could not find driver error is a hardware/software compatibility flag rather than a code logic error. By aligning your PHP extensions with your database configuration, you restore the communication channel required for Laravel to manage its schema evolution effectively. For more robust local development setups that avoid these extension headaches entirely, many teams opt for Vagrant or Docker-based environments like those found at https://laravelcompany.com, which abstract away the underlying OS and PHP configuration complexities.

Our network