◆エラー内容
PS C:UsersuserDocumentsMEGASOHOMENTAsrcsales> php artisan migrate
IlluminateDatabaseQueryException : could not find driver (SQL: select * from information_schema.tables where table_schema = sale and table_name = migrations and table_type = 'BASE TABLE')
at C:UsersuserDocumentsMEGASOHOMENTAsrcsalesvendorlaravelframeworksrcIlluminateDatabaseConnection.php:669
665| // If an exception occurs when attempting to run a query, we'll format the error
666| // message to include the bindings with SQL, which will make this exception a
667| // lot more helpful to the developer instead of just the database's errors.
668| catch (Exception $e) {
> 669| throw new QueryException(
670| $query, $this->prepareBindings($bindings), $e
671| );
672| }
673|
Exception trace:
1 DoctrineDBALDriverPDOException::("could not find driver")
C:UsersuserDocumentsMEGASOHOMENTAsrcsalesvendordoctrinedballibDoctrineDBALDriverPDOConnection.php:31
2 PDOException::("could not find driver")
C:UsersuserDocumentsMEGASOHOMENTAsrcsalesvendordoctrinedballibDoctrineDBALDriverPDOConnection.php:27
Please use the argument -v to see more details.
PS C:UsersuserDocumentsMEGASOHOMENTAsrcsales>
.envのデータベース名もあっているし、データベースも作成されている。どうもPDOが接続できないようです。
◆原因
php格納場所を where コマンドで確認
C:UsersuserDocumentsMEGASOHOMENTAsrcsales>where php
C:phpphp.exe
cd で 該当ディレクトリで移動し php.ini を開く
![](https://i0.wp.com/system-sutaruhin.com/wp-content/uploads/2020/06/d935b0d3dda0d714ca2d3d74cae8a21f.png?w=1256&ssl=1)
phpinfoはブラウザ経由で見ましたが、extension=pdo_mysql (PDO)がPHPで指定されていませんでした
◆対策
php.ini を変更します
extension=pdo_mysql
を生かしましょう
これで無事にマイグレーションできました
![](https://i0.wp.com/image.moshimo.com/af-img/1115/000000025658.png?resize=449%2C178)
![](https://i0.wp.com/image.moshimo.com/af-img/0032/000000000639.gif?resize=468%2C60)