Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

QueryException SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

Tags:

mysql

laravel

Why is the following error occurring?

QueryException SQLSTATE[HY000] [1045] Access denied for user 'homestead'@'localhost' (using password: YES)

My .env file is as follows:

APP_NAME=Laravel
APP_ENV=local
APP_KEY=base64:P7auDP3AGgfkYLPbu+2/m7RCLc42Sip/HuXLLQFZiYs=
APP_DEBUG=true
APP_LOG_LEVEL=debug
APP_URL=http://localhost

DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=student_management
DB_USERNAME=root
DB_PASSWORD=
like image 530
Tazwar Utshas Avatar asked Jun 10 '17 04:06

Tazwar Utshas


2 Answers

You should clear the cache after changing info in the .env file.

Run the following commands:

php artisan cache:clear 
php artisan config:clear 
php artisan config:cache  
like image 170
Vishal Varshney Avatar answered Nov 10 '22 01:11

Vishal Varshney


It's either you edit a wrong file or you have not saved the .env yet. Because in your error message, it looks like you access the database using user homestead on localhost database, not root on student_management. Make sure you edit the correct .env, not .env.example. cheers

like image 25
Matias Alvin Avatar answered Nov 09 '22 23:11

Matias Alvin