Miyuki Ouka
Miyuki Ouka

Reputation: 35

Illuminate\Database\QueryException : could not find driver Error

I have an error when trying to execute the command

php artisan migrate

on my Windows command prompt I've already tried many solutions from the internet by uncommenting

extension=pdo_mysql 

in my php.ini configuration on Xampp but it still not working, is there any working solution to solve this problem?

ERROR:

enter image description here

Upvotes: 3

Views: 9747

Answers (5)

Udhav Sarvaiya
Udhav Sarvaiya

Reputation: 10071

Run Following command:

composer require doctrine/dbal
composer update

It looks like you have a missing dependency it showing error on your image.

Also Windows users, PDO and all the major drivers ship with PHP as shared extensions, and simply need to be activated by editing the php.ini file:

extension=php_pdo.dll

Note: This step is not necessary for PHP 5.3 and above, as a DLL is no longer required for PDO.

Upvotes: 0

Miyuki Ouka
Miyuki Ouka

Reputation: 35

okay, I think I just realized something, I run php command from my cmd and after I deleting php directory on C:, the php command is gone, so I assume I have to run the command from Xampp shell in order to give a command to php in Xampp service, it works with that way, thank you

Upvotes: 0

Muhammad Bilal
Muhammad Bilal

Reputation: 2134

You might need to un-comment extension=php_pdo_mysql.dll.

Dont forget to restart xampp after un-commenting.

Upvotes: 0

Boni
Boni

Reputation: 348

go to "config" folder of your project and open database.php

and replace with this code

   'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', '127.0.0.1'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'forge'),
        'username' => env('DB_USERNAME', 'forge'),
        'password' => env('DB_PASSWORD', ''),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => 'InnoDB',
    ],

Upvotes: 3

Rajesh
Rajesh

Reputation: 181

you can use First check php version by using php --version and install the corresponding driver.

sudo apt-get install php7-mysql

Or

sudo apt-get install php5-mysql

or

sudo apt-get install php-mysql

Upvotes: 1

Related Questions