ホーム > Laravel > How to Resolve 'could not find driver' Error in Laravel
Laravel

How to Resolve 'could not find driver' Error in Laravel

Thank you for your continued support.
This article contains advertisements that help fund our operations.

This article explains how to resolve the 'could not find driver' error when running php artisan migrate in Laravel.

Error Message

Illuminate\Database\QueryException
could not find driver (Connection: mysql, SQL ....)

Environment

AWS EC2 (Amazon Linux 2023)
PHP 8.3
Laravel 11

Solution

The issue was resolved by installing the missing php-mysqlnd package.

sudo dnf install -y php-mysqlnd

Background

While deploying a Laravel project on AWS EC2 (Amazon Linux 2023), I encountered the following error when running:

php artisan migrate

Previously, I had only run the following command for PHP:

sudo dnf install -y php8.3

Unlike yum, dnf automatically installs various necessary drivers with just one command, and I saw logs indicating that it was doing so. Based on that, I thought this single command would suffice.

However, the error occurred only during migration, so I ran one additional command to resolve the issue.

The solution may vary depending on your environment and approach, but I hope this helps someone facing the same issue.

Please Provide Feedback
We would appreciate your feedback on this article. Feel free to leave a comment on any relevant YouTube video or reach out through the contact form. Thank you!