Laravel 5.4 sometimes uses different database credentials

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

I've changed the .env variables to my local MySQL Server already... and as I said it ONLY happens SOMETIMES (rarely)...

I'm able to force the issue to happen by spamming an ajax request that I created.

I did NOT tell Laravel to use a secondary database connection anywhere (unless there's an alternate connection by default when you first install).

Here's the error.

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


Yes, I had that problem and solved by typing in terminal:

php artisan config:cache

As I think it happens because sometimes it can't read .env file.

链接地址: http://www.djcxy.com/p/33074.html

上一篇: 在laravel的.env文件中使用loacalhost vs127.0.0.1

下一篇: Laravel 5.4有时使用不同的数据库凭证