2

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

marc_s
  • 732,580
  • 175
  • 1,330
  • 1,459
Miyuki Ouka
  • 25
  • 1
  • 6

5 Answers5

2

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',
    ],
Boni
  • 338
  • 2
  • 13
1

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
Rajesh
  • 181
  • 1
  • 11
  • @MiyukiOuka Which PHP version are you using? – Rajesh Jan 03 '19 at 06:39
  • @MiyukiOuka This can happen for a Number of reasons. Either the Default DB type is not set (config/database.php), or the Extension is not enabled, or you HAVE enabled the extension but have NOT restarted XAMPP, or the PATH settings under environment settings are not properly defined. I suggest you check out this answer which may solve the issue: https://stackoverflow.com/a/25336292/2745485 – Rajesh Jan 03 '19 at 06:42
  • I'm using php version 7.3.0 – Miyuki Ouka Jan 03 '19 at 06:49
0

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

Dont forget to restart xampp after un-commenting.

Muhammad Bilal
  • 2,106
  • 1
  • 15
  • 24
0

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.

Udhav Sarvaiya
  • 9,380
  • 13
  • 53
  • 64
0

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

Miyuki Ouka
  • 25
  • 1
  • 6