5

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?

2

8 Answers 8

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

Sign up to request clarification or add additional context in comments.

Comments

5

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

 ./vendor/bin/sail artisan migrate

not php artisan migrate

1 Comment

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.
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',
        ],
    ],
],

Comments

0

Run the following two commands for ubuntu:

sudo apt install php-mysql
sudo /opt/lampp/lampp restart

Comments

0

Go to PHP.ini file and watch for extension_dir

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

2 Comments

extension_dir = "C:\MAMP\bin\php\php8.1.0\ext"
So its php version 8 for you
0

Open XAMPP and start MySQL – it worked for me.

Comments

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 Comment

Please translate your answer in English.
-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

Comments

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.