3

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

1
  • Hello, At the end, what did you do for this issue? Commented Aug 26, 2021 at 7:06

5 Answers 5

3

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',
    ],
Sign up to request clarification or add additional context in comments.

6 Comments

it still the same
please change your php version to 7.2 and restart your server
I've already installed the Xampp with php version 7.2 but it doesn't work
did you make changes in database.php if you did my suggestion is to reinstall laravel and do change in database.php and try php artisan migrate i think this will work
no, I didn't I just make new database in MySQL and then run php artisan make:controller CreatesContoller and php artisan make:model Article -m to create controller and migration
|
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

3 Comments

@MiyukiOuka Which PHP version are you using?
@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: stackoverflow.com/a/25336292/2745485
I'm using php version 7.3.0
0

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

Dont forget to restart xampp after un-commenting.

Comments

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

Comments

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.

8 Comments

@MiyukiOuka What happened after trying?
it still the same
@MiyukiOuka for testing purpose: create a new database and set in .env file after run php artisan migrate command execute, try it maybe it helps you
Okay, when you get a solution, please post as an answer :)
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
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.