Access denied for user ‘homestead’@’localhost’ laravel 5
The reason of Access denied for user ‘homestead’@’localhost’ laravel 5 error is caching-issue of the .env.php file cause Laravel 5 is using environment based configuration in your .env file. You will see a .env.example file in the root directory of your application. If you are installing Laravel via Composer, this file will automatically be renamed to .env. else, you need to rename the file manually.
default .env file looks like
APP_ENV=local APP_DEBUG=true APP_KEY=your_key DB_HOST=localhost DB_DATABASE=homestead DB_USERNAME=homestead DB_PASSWORD=secret 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
Solving this error
Step 1 :
Go to your application root directory and open .env file (In ubuntu may be it’s hidden so press ctrl+h to show hidden files) in your editor and change database configuration setting. then save your .env file
DB_HOST=localhost DB_DATABASE=laravelu DB_USERNAME=root DB_PASSWORD=
Step 2 :
then restart your apache server/web server. and refresh your page and you have done
Step 3 :
If still issue try to run below command to clear the old configuration cache file.
php artisan config:clear
Now you are done with Access denied for user ‘homestead’@’localhost’ laravel 5