When i write some data trough laravel/lumen code to mysql it works most of the time but randomly fails with:
SQLSTATE[HY000] [1044] Access denied for user ''@'localhost' to database 'forge'
Code:
for($items as $item) {
$ItemCollection = ItemCollection::where([
['id', '=', $ItemCollectionId],
['finished', '=', 0],
])->first();
$Item = new Item(['item_id' => $item->id]);
$ItemCollection->items()->save($item);
if ($ItemCollection->items()->count() === $ItemCollection->itemCount) {
$ItemCollection->finished = 1;
$ItemCollection->save();
}
}
My .env looks like this:
APP_ENV=local
APP_DEBUG=true
APP_KEY=
APP_TIMEZONE=UTC
DB_CONNECTION=mysql
DB_HOST=localhost
DB_PORT=3306
DB_DATABASE=laravel
DB_USERNAME=root
DB_PASSWORD=
CACHE_DRIVER=memcached
QUEUE_DRIVER=sync
Does anyone have a idea where it is going wrong?