I\'m on a Mac OS Yosemite using Laravel 5.0.
While in my local environment, I run php artisan migrate
I keep getting :
Check your .env file, if you have edited any of the variables, kindly restart laravel server, and your problem will be solved
I had the same issue using SQLite. My problem was that DB_DATABASE was pointing to the wrong file location.
Create the sqlite file with the touch command and output the file path using php artisan tinker.
$ touch database/database.sqlite
$ php artisan tinker
Psy Shell v0.8.0 (PHP 5.6.27 — cli) by Justin Hileman
>>> database_path(‘database.sqlite’)
=> "/Users/connorleech/Projects/laravel-5-rest-api/database/database.sqlite"
Then output that exact path to the DB_DATABASE variable.
DB_CONNECTION=sqlite
DB_HOST=127.0.0.1
DB_PORT=3306
DB_DATABASE=/Users/connorleech/Projects/laravel-5-rest-api/database/database.sqlite
DB_USERNAME=homestead
DB_PASSWORD=secret
Without the correct path you will get the access denied error
From your question, it seems you are running homestead. In that case, make sure you're running the commands in your VM. Many devs including me often make mistake and run artisan commands outside of VM which the commands will try to connect to our local database accessible through localhost which is different from the database used by homestead. Cd to your Homestead directory and run
vagrant ssh
then cd into code if that is where you keep your projects and cd into your project and run php artisan migrate again
I hope this will help other people.
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.
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 & if you are in terminal then type : ls -a
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=''
2. then restart your apache server/web server. and refresh your page and you have done
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 the error
I just wanted to post this because this issue frustrated me for about 3 hours today. I have not tried any of the methods listed in the other answers, though they all seem reasonable. In fact, I was just about to try going through each of the above proposed solutions, but somehow I got this stroke of inspiration. Here is what worked for me to get me back working -- YMMV:
1) Find your .env file. 2) Rename your .env file to something else. Laravel 5 must be using this file as an override for settings somewhere else in the framework. I renamed mine to .env.old 3) You may need to restart your web server, but I did not have to.
Good luck!
A. After updating the .env file with database settings, clear larval setting by "running php artisan config:clear"
B. Please make sure you restart your apache server / rerun the "php artisan serve" command for your settings to take effect.