0

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?

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39
ALBADI
  • 315
  • 2
  • 8
  • 17
  • is this relevent? https://github.com/laradock/laradock/issues/1390 – delboy1978uk Oct 26 '18 at 15:15
  • apparently you might need to downgrade mysql, but check the guys answer below first – delboy1978uk Oct 26 '18 at 15:16
  • https://mysqlserverteam.com/mysql-8-0-4-new-default-authentication-plugin-caching_sha2_password/ – delboy1978uk Oct 26 '18 at 15:16
  • See the post: [https://stackoverflow.com/questions/50547724/how-to-resolve-the-error-sql-authentication-method-unknown-in-laravel-mysql](https://stackoverflow.com/questions/50547724/how-to-resolve-the-error-sql-authentication-method-unknown-in-laravel-mysql) – Ragner Moura Oct 26 '18 at 15:16
  • Please don't share your DB password. Make it `xxxx` by editing your post. – nice_dev Oct 26 '18 at 15:23

3 Answers3

0

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',
        ],
Michael
  • 47
  • 9
0

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.

Michael
  • 47
  • 9
0

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

delboy1978uk
  • 12,118
  • 2
  • 21
  • 39