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
7
  • WHat is exact error message? Commented Aug 31, 2016 at 15:43
  • make sure your username and password is correct, and if you can edit your question with the exact message error Commented Aug 31, 2016 at 15:44
  • i have done editing my question with exact error message Commented Aug 31, 2016 at 15:49
  • Is your password actually my password with a space? if so wrap it in ' ' DB_PASSWORD='my password' Commented Aug 31, 2016 at 15:56
  • No that's not my reall password there is real password but i don't wanna put it here Commented Aug 31, 2016 at 15:59

2 Answers 2

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.

Sign up to request clarification or add additional context in comments.

Comments

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.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.