Laravel Error (database connection for Windows)

Error type: image.png

Solution: In AppServiceProvider, found under app/provider, add these:

use Illuminate\Support\Facades\Schema;

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

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

No Comments Yet