0
votes

I am trying to migrate a table to a database called kokodb in laravel. However, I keep getting this error :

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from information_schema.tables where table_schema = kokodb and table_name = migrations)

This is my env file:

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=kokodb
DB_USERNAME=*****
DB_PASSWORD=*****

and this is the database.php code:

    'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST', 'localhost'),
        'port' => env('DB_PORT', '3306'),
        'database' => env('DB_DATABASE', 'kokodb'),
        'username' => env('DB_USERNAME', 'root'),
        'password' => env('DB_PASSWORD', 'ZAQ!2wsx'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,

What is the possible solution to this error?

3
apparently you might need to downgrade mysql, but check the guys answer below firstdelboy1978uk
Please don't share your DB password. Make it xxxx by editing your post.nice_dev

3 Answers

0
votes

For me, actually running artisan commands inside the workspace container solved the same problem I had. Check out the Laravel run artisan commands.

And adding following code at the end of config/database.php, afert 'engine':

        'modes'  => [
            'ONLY_FULL_GROUP_BY',
            'STRICT_TRANS_TABLES',
            'NO_ZERO_IN_DATE',
            'NO_ZERO_DATE',
            'ERROR_FOR_DIVISION_BY_ZERO',
            'NO_ENGINE_SUBSTITUTION',
        ],
0
votes

Remove the values from

'mysql' => [
        'driver' => 'mysql',
        'host' => env('DB_HOST'),
        'port' => env('DB_PORT'),
        'database' => env('DB_DATABASE'),
        'username' => env('DB_USERNAME'),
        'password' => env('DB_PASSWORD'),
        'unix_socket' => env('DB_SOCKET', ''),
        'charset' => 'utf8mb4',
        'collation' => 'utf8mb4_unicode_ci',
        'prefix' => '',
        'strict' => true,
        'engine' => null,

just like that, the ENV file already passes the information. Maybe it get's passed twice.

0
votes

Pasted from another OP's "question" which was actually an answer and not a question:

This error appear in PHP Symfony4 /PDO Doctrine with MySql 8.0.13

For my is working after this 3 steps:

Add this line to my.cnf

default_authentication_plugin=mysql_native_password

restart mysql server

Create a new MySql user/password and change it in your .env file

Without step 3, the old user is keeping the Authentication Type: "caching_sha2_password" After create a new user, then the new user will use Authentication Type: "mysql_native_password"

PS This is because of new Authentication Type in MySql 8.0.13 Server