如何使用laravel 5连接到db

I updated my laravel4 to laravel5 now my problem is i cant connect to database

My mysql

'mysql' => [
    'driver'    => 'mysql',
    'host'      => env('DB_HOST', 'localhost'),
    'database'  => env('DB_DATABASE', 'lue'),
    'username'  => env('DB_USERNAME', 'root'),
    'password'  => env('DB_PASSWORD', ' '),
    'charset'   => 'utf8',
    'collation' => 'utf8_unicode_ci',
    'prefix'    => '',
    'strict'    => false,
],

i returns this problem

PDOException in Connector.php line 47:
SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

help :)

You need to edit your .env file in the root of your application and change the DB username and password there

You need to edit your .env file in the root of your application. Just configure as following example:

APP_ENV=local

APP_DEBUG=true

APP_KEY=6CqAQJdOd8oKoh0NhbefkmS0Pd8FDH6h

DB_HOST=localhost

DB_DATABASE=your database name

DB_USERNAME=your database user name

DB_PASSWORD=your password

CACHE_DRIVER=file

SESSION_DRIVER=file

Make sure you are editing the .env file, and not a .env.php file. In Laravel 4 there was a way to use .env.environment.php but in Laravel 5 it's all done with a .env file (note that it doesn't have a php suffix)

Also the data in the .env file must not be in the array format. It should just be as follows:

APP_ENV=local
APP_DEBUG=true
APP_KEY=longstring
DB_HOST=localhost
DB_DATABASE=dbname
DB_USERNAME=homestead
DB_PASSWORD=secret

I had the same problem and this is how I fixed it.
Go to the root of your laravel folder (application folder) in my case it is C:\firstapp and open .env file in notepad++
Update the following code accordingly.

DB_HOST=localhost 
DB_DATABASE=firstapp (this is database name)
DB_USERNAME=root (user name)
DB_PASSWORD= (password , leave empty if none , do not even put "")

Important
and then restart your application like this php artisan serve (using command line) while you are in the root of you application folder. See this image for clarification link.