3

I have the following error upon doing:

php artisan migrate

Error:

Illuminate\Database\QueryException : SQLSTATE[HY000] [2054] The server requested authenti cation method unknown to the client (SQL: select * from information_schema.tables where table _schema = d1 and table_name = migrations)

Here's a screenshot;

enter image description here

PS. Just in case: I've enabled the "extension=pdo_mysql" in my php.ini file.

Any ideas how to fix this?

Daniel
  • 2,367
  • 9
  • 22
  • 30
Andrey Kurnikovs
  • 387
  • 1
  • 3
  • 18

4 Answers4

6

Hi as mentioned in this post:

Laravel-news

it is a typical windows problem.

The mentioned solution is:

use Illuminate\Support\Facades\Schema;

public function boot()
{
    Schema::defaultStringLength(191);
}

inside the AppServiceProvider.php

Krie9er
  • 101
  • 2
  • 5
2

If you use Macos+docker+mysql. then use this

 ./vendor/bin/sail artisan migrate

not php artisan migrate

simon
  • 21
  • 1
  • Your answer could be improved with additional supporting information. Please [edit] to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers [in the help center](/help/how-to-answer). – Community Jan 05 '22 at 11:18
0

I have also been stuck on this for quite some time. One solution that worked for me was to open Connection.php and either comment out the exceptions or replace those exceptions so that there is no error when php migrate is run. This worked for me. Let me know if you find any other solutions/any changes.

Alternatively, and perhaps a better solution:

In database.php, found under app/config, add this:

'connections' => [

    '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'      => null,
        'modes'       => [
            'ONLY_FULL_GROUP_BY',
            'STRICT_TRANS_TABLES',
            'NO_ZERO_IN_DATE',
            'NO_ZERO_DATE',
            'ERROR_FOR_DIVISION_BY_ZERO',
            'NO_ENGINE_SUBSTITUTION',
        ],
    ],
],
fattalico
  • 21
  • 1
  • 9
-1

Been struggling with this problem too. I think it's better to drop and then migrate again the tables first before adding a new table or any changes to your migrations folder. I hope this will solve your problem..

php artisan migrate:fresh