1

I'm just a beginner of laravel and when an trying to Work with models just that error pop up and the exact error message is :

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

Here is my route code :

 route::get('customer', function(){
    $customer = App\customer::find(1);
    echo $customer->name;
    });

and here is my .env file

 APP_ENV=local
APP_KEY=base64:YP84cuDiwIkv4iCqrEEWMQBdOklL2+coODVf9qB6HwY=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=my password

CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync

REDIS_HOST=127.0.0.1
REDIS_PASSWORD=null
REDIS_PORT=6379

MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
MAIL_ENCRYPTION=null
Khaled
  • 23
  • 1
  • 6

2 Answers2

1

For this issue please do following steps -

1. php artisan config:clear
2. php artisan cache:clear
3. php artisan serve

If it is still not working then make changes in config/database.php as -

    'database' => env('DB_DATABASE', 'laravel'),
    'username' => env('DB_USERNAME', 'root'),
    'password' => env('DB_PASSWORD', 'root'),
    'strict' => false,

Hope this will work for you.

Suniti Yadav
  • 393
  • 2
  • 8
0

I got a similar problem. I started my server using php artisan serve command, and edited the .env file and refreshed the web-page which did not reflect any changes!

I fixed it by stopping the webserver, editing the .env.php file and restarting the webserver!

So I guess it's a caching-issue of the .env.php file.