Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

why .env file configuration in laravel is not working

DB_CONNECTION=mysql      
DB_HOST=127.0.0.1     
DB_PORT=3306     
DB_DATABASE=
DB_USERNAME=root     
DB_PASSWORD=   

this is my configuration for laravel 5.4 but php artisan migrate is not working and have error and the migrate error

Users-MacBook-Pro: ATP Developers php artisan migrate

In Connection.php line 664: 
SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO) (SQL: select * from information_schema.tables where table schema = atp_db and table_name = migrations)

In Connector.php line 87:
SQLSTATE[HY000] [1045] Access denied for user ''@'localhost' (using password: NO)
like image 935
Najib jamshidi Avatar asked Jan 21 '18 11:01

Najib jamshidi


3 Answers

I faced a similar problem. So, I run the following commands as mentioned at https://laracasts.com/discuss/channels/general-discussion/env-file-and-config-keys-not-updating-after-change, php artisan cache:clear php artisan config:clear php artisan route:clear

Also, make sure to restart the server as well

php artisan serve
like image 111
Faraz Ahmad Avatar answered Oct 09 '22 11:10

Faraz Ahmad


you should write these:

DB_DATABASE = your database name
DB_USERNAME = root     
DB_PASSWORD = your password

and again run php artisan serve to make sure about saving .env and again run php artisan migrate

like image 34
parastoo Avatar answered Oct 09 '22 11:10

parastoo


Indeed I had the same problem, I can not explain why Laravel indicates the old Host but the solution is to change the password.

Use below => php artisan config:cache

like image 1
Jérémy Cornut Avatar answered Oct 09 '22 10:10

Jérémy Cornut