如何使用MAMP将我的Laravel 5应用程序连接到mysql?

I've gotten several different errors running php artisan migrate while trying different things. The most recent one is:

Access denied for user 'homestead'@'localhost' (using password: YES

This is my database.php

'mysql' => [
    'driver'    => 'mysql',
    'host'      => env('DB_HOST', 'localhost'),
    'unix_socket'   => '/Applications/MAMP/tmp/mysql/mysql.sock',
    'database'  => env('DB_DATABASE', 'forge'),
    'username'  => env('DB_USERNAME', 'forge'),
    'password'  => env('DB_PASSWORD', ''),
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
    'strict'    => false,
    'port' => '3306'
],

and this is the .env

APP_ENV=local
APP_DEBUG=true
APP_KEY=halMyGPhfVZGrdpibFIwEE0wZipP5lqu

DB_HOST=localhost *updated
DB_DATABASE=forge *updated
DB_USERNAME=forge *updated
DB_PASSWORD= *updated

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null

UNIX_SOCKET=/Applications/MAMP/tmp/mysql/mysql.sock

Try changing the following in your .env file or remove all the keys related to DB from .env file.

DB_HOST=localhost
DB_DATABASE=forge
DB_USERNAME=forge
DB_PASSWORD=

I had run into same issue, The problem is, the database.php file looks for the key DB_DATABASE etc. in the .env file. Since, that key is present in .env file, It doesn't consider the default value forge that you have provided in the statement env('DB_DATABASE', 'forge')

In plain english, "Look for the key DB_DATABASE in .env, if present, use that else use forge as default"

In your case, the keys are present in .env file hence, though you provide forge, it considers homestead that is defined in the .env file. And hence the error Access denied on 'homestead'@'localhost'

Hope I clarified the things.