4

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,355
  • 9
  • 23
  • 30
Andrey Kurnikovs
  • 407
  • 1
  • 5
  • 21

8 Answers8

7

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
  • 111
  • 2
  • 5
3

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

 ./vendor/bin/sail artisan migrate

not php artisan migrate

simon
  • 31
  • 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
0

Run the following two commands for ubuntu:

sudo apt install php-mysql
sudo /opt/lampp/lampp restart
Safaetul Ahasan Piyas
  • 1,285
  • 1
  • 8
  • 10
0

Go to PHP.ini file and watch for extension_dir

It should be aligned with the php version of your project.

0

Open XAMPP and start MySQL – it worked for me.

Wongjn
  • 8,544
  • 2
  • 8
  • 24
Bảo Long
  • 51
  • 2
0

Resolveu pra mim da seguinte forma:

Em AppServiceProvider.php dentro da pasta app.Providers inclua informações abaixo.

use Illuminate\Support\Facades\Schema;

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

Desta forma deve resolver o problema!

-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