Laravel 5.4 sometimes uses different database credentials

Laravel 5.4 randomly (sometimes not always or even often) tries to connect to the database using the default forge credentials ...

I changed the .env variables to my local MySQL server already ... and, as I said, it ONLY happens sometimes (rarely) ...

I can make the problem happen by sending the ajax spam request I created.

I did NOT tell Laravel to use an additional database connection anywhere (if there is no alternative connection during the first installation).

This is a mistake.

QueryException in line Connection.php 647: SQLSTATE [HY000] [1045] Access denied for user 'forge' @ 'localhost' (using password: NO) (SQL: select * from users, where users. id= 2 limit 1)

+4
source share
1 answer

Yes, I had this problem and was solved by typing the terminal:

php artisan config:cache

I think this is because sometimes it cannot read the file .env.

+3
source

Source: https://habr.com/ru/post/1668304/


All Articles