I'm trying to connect with PHP and MySQL through the database using Laravel doing:
php artisan migrate
but I'm experiencing a common error:
"Illuminate\Database\QueryException : could not find driver"
(I'm using XAMPP to start up the server if that makes a difference)
The values I changed in database.php:
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '3308'),
'database' => env('DB_DATABASE', 'test2'),
'username' => env('DB_USERNAME', 'root'),
'password' => env('DB_PASSWORD', ''),
'unix_socket' => env('DB_SOCKET', ''),
'charset' => 'utf8mb4',
'collation' => 'utf8mb4_unicode_ci',
'prefix' => '',
'prefix_indexes' => true,
'strict' => true,
'engine' => null,
],
I also changed the .env file:
DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3308
DB_DATABASE=test2
DB_USERNAME=root
DB_PASSWORD=
The things I did were:
- See if the
extension=pdo_mysql
is uncommented which it was. - Typed in
php artisan migrate:refresh
- Restarted Xampp
- Deleted and recreated the migration file. Also incremented the last digit of the number (taken advice from one of the answers)
- Check the version (which is the latest)