php artisan migrate throwing [PDO Exception] Could not find driver - Using Laravel

Stefan Izdrail

Founder & Senior Architect · 2026-06-29

Laravel Company
Title: Resolving PDOException Issues During Laravel's artisan migrate Command Introduction It is common to encounter issues when starting out with Laravel projects or making changes to existing ones. The experience of dealing with errors like [PDO Exception] could not find driver can be frustrating, especially because it halts your workflow and prevents you from proceeding further in the development process. This comprehensive blog post aims to provide a well-explained solution for this PDOException issue while running php artisan migrate command using Laravel. Understanding the Problem: PDOException and Missing Driver PDOException is thrown when there's an error establishing a connection with the database, which prevents further tasks from proceeding. The most common cause of this error is the missing driver for the specific database engine you are using. In Laravel, to deal with multiple databases simultaneously, it uses PDO drivers as abstraction layers. If any of these drivers are missing or incorrectly configured in your php.ini file, Laravel won't be able to establish a connection and will throw this exception. Resolving the Problem: Configuring Php.Ini File for Missing Drivers As suggested by fellow developers on Stack Overflow and Laravel forums, you might have added extensions in your php.ini file to include missing drivers as follows:
extension=pgsql.so
extension=pdo_pgsql.so
However, these steps may not solve the issue entirely or you might be using a different database engine altogether. You need to ensure that your php.ini file is configured correctly for the specific PDO driver you require. Here's how: 1. Identify the required PDO driver: The above-mentioned code snippet targets only pgsql and pdo_pgsql. If you are using a different database engine, such as MySQL or PostgreSQL, you need to find its relevant extensions and add them in php.ini. For MYSQL/MariaDB: extension=mysql.so For PostgreSQL: extension=pgsql.so, extension=pdo_pgsql.so 2. Ensure the correct driver is enabled: Check if your current configuration has already added the missing driver by opening php.ini and searching for the respective extensions. If not found, add them to the end of the file, following the same format as shown in our example code snippet above. 3. Restarting PHP or Apache to refresh configurations: After making changes to your php.ini file, restart either the PHP interpreter (php -r "phpinfo();") or restart Apache server if you are using MAMP or a similar software. This ensures that your updated configuration is loaded and will be used during runtime. 4. Re-run artisan migrate: Once the PDO driver is correctly configured, run php artisan migrate again to check whether it still throws an exception or not. If everything goes well without any errors, you have successfully resolved the problem. Conclusion Dealing with PDOException issues in Laravel can be frustrating but they're relatively easy to tackle if you know how to configure your environment properly. By following these steps and making sure that the right drivers are enabled on your php.ini file, you should be able to get back on track with your Laravel project without any further hiccups. For additional assistance or clarification, feel free to refer back to https://laravelcompany.com/resources for more in-depth knowledge and support from experienced developers.