1
resposta

SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client

Boa tarde, ao realizar a aula MVC e conexão com banco de dados me deparei com o seguinte problema(Illuminate \ Database \ QueryException (2054) SQLSTATE[HY000] [2054] The server requested authentication method unknown to the client (SQL: select * from produtos)) , porém não consegui resolver o mesmo, alguém poderia me da uma ajuda ? segue abaixo o codigo do ProdutoController.

<?php namespace App\Http\Controllers;
use Illuminate\Support\Facades\DB;
    class ProdutoController extends Controller{
        public function lista(){
            $produtos = DB::select ('select * from produtos');
            dd($produtos);
            return '<h1>Lista de produto</h1>';
        }}

Segue abaixo o código do config/database

<?php

return [

    /*
    |--------------------------------------------------------------------------
    | Default  Connection Name
    |--------------------------------------------------------------------------
    |
    | Here you may specify which of the  connections below you wish
    | to use as your default connection for all  work. Of course
    | you may use many connections at once using the  library.
    |
    */

    'default' => env('DB_CONNECTION', 'mysql'),

    /*
    |--------------------------------------------------------------------------
    |  Connections
    |--------------------------------------------------------------------------
    |
    | Here are each of the  connections setup for your application.
    | Of course, examples of configuring each  platform that is
    | supported by Laravel is shown below to make development simple.
    |
    |
    | All  work in Laravel is done through the PHP PDO facilities
    | so make sure you have the driver for your particular  of
    | choice installed on your machine before you begin development.
    |
    */

    'connections' => [

        'sqlite' => [
            'driver' => 'sqlite',
            'database' => storage_path().'/database.sqlite',
            'prefix' => '',
        ],

       'mysql' => [
            'driver'    => 'mysql',
            'host'      => env('DB_HOST', 'localhost'),
            'database'  => env('estoque_laravel', 'forge'),
            'username'  => env('root', 'forge'),
            'password'  => env('1234', ''),
            'charset'   => 'utf8',
            'collation' => 'utf8_unicode_ci',
            'prefix'    => '',
            'strict'    => false,
            'engine' => null,
        ],


        'pgsql' => [
            'driver' => 'pgsql',
            'host' => env('DB_HOST', '127.0.0.1'),
            'port' => env('DB_PORT', '5432'),
            '' => env('DB_', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
            'schema' => 'public',
            'sslmode' => 'prefer',
        ],

        'sqlsrv' => [
            'driver' => 'sqlsrv',
            'host' => env('DB_HOST', 'localhost'),
            'port' => env('DB_PORT', '1433'),
            '' => env('DB_', 'forge'),
            'username' => env('DB_USERNAME', 'forge'),
            'password' => env('DB_PASSWORD', ''),
            'charset' => 'utf8',
            'prefix' => '',
        ],

    ],

    /*
    |--------------------------------------------------------------------------
    | Migration Repository Table
    |--------------------------------------------------------------------------
    |
    | This table keeps track of all the migrations that have already run for
    | your application. Using this information, we can determine which of
    | the migrations on disk haven't actually been run in the .
    |
    */

    'migrations' => 'migrations',

    /*
    |--------------------------------------------------------------------------
    | Redis s
    |--------------------------------------------------------------------------
    |
    | Redis is an open source, fast, and advanced key-value store that also
    | provides a richer set of commands than a typical key-value systems
    | such as APC or Memcached. Laravel makes it easy to dig right in.
    |
    */

    'redis' => [

        'client' => 'predis',

        'default' => [
            'host' => env('REDIS_HOST', '127.0.0.1'),
            'password' => env('REDIS_PASSWORD', null),
            'port' => env('REDIS_PORT', 6379),
            '' => 0,
        ],

    ],

];
1 resposta

Oi Patrick, vc conferiu as suas credenciais, usuario e senha?

To achando que pode ser isso.

Abraços!