Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5 app keeps using old database connection

Tags:

laravel-5

PDOExceptionvendor/laravel/framework/src/Illuminate/Database/Connectors/Connector.php:47

SQLSTATE[HY000] [1045] Access denied for user 'forge'@'localhost' (using password: YES)

I have updated .env file with the correct credentials (its not even localhost anymore, its an IP address) however I keep getting this error message. I have already run php artisan config:clear as well too. How can I force a production app to use the new credentials in its .env file?

My config/database.php is standard:

'connections' => [
       'mysql' => [
           'driver'    => 'mysql',
           'host'      => env('DB_HOST', 'localhost'),
           'database'  => env('DB_DATABASE'),
           'username'  => env('DB_USERNAME'),
           'password'  => env('DB_PASSWORD'),
           'port'      => env('DB_PORT', '3306'),
           'charset'   => 'utf8',
           'collation' => 'utf8_unicode_ci',
           'prefix'    => '',
           'strict'    => false,
    ],

],
like image 956
Anthony Vipond Avatar asked Dec 01 '22 00:12

Anthony Vipond


2 Answers

Run the following Artisan commands then try again:

php artisan cache:clear

php artisan config:clear

php artisan config:cache

php artisan route:clear

php artisan route:cache
like image 179
Karthik SWOT Avatar answered Dec 04 '22 05:12

Karthik SWOT


Good lord, almost lost my mind trying fix this. There was no problem with the DB connection on the web requests, but I was still getting connection errors in my bug reporting. Seems the issue was the queue we were running was holding the old config values.

ps aux | grep php

Find the queue:work process and kill it, it will start up again automatically but read in your new config values.

like image 40
Anthony Vipond Avatar answered Dec 04 '22 04:12

Anthony Vipond