Reputation: 1957
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,
],
],
Upvotes: 5
Views: 7730
Reputation: 8558
Step 1: Please remove the file config.php
from the mentioned path project_name\bootstrap\cache
Step 2: Now, Run the commands which are mentioned below:
composer dump-autoload
php artisan clear-compiled
php artisan config:clear
php artisan cache:clear
php artisan config:cache
Hope, it will work for you.
Upvotes: 0
Reputation: 1217
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
Upvotes: 15
Reputation: 1957
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.
Upvotes: 3
Reputation: 124
.env file
APP_ENV=local
APP_DEBUG=true
APP_KEY=SomeRandomString
DB_HOST=localhost
DB_DATABASE=homestead
DB_USERNAME=homestead
DB_PASSWORD=secret
CACHE_DRIVER=file
SESSION_DRIVER=file
QUEUE_DRIVER=sync
MAIL_DRIVER=smtp
MAIL_HOST=mailtrap.io
MAIL_PORT=2525
MAIL_USERNAME=null
MAIL_PASSWORD=null
config/database.php
'mysql' => [
'driver' => 'mysql',
'host' => env('DB_HOST', 'localhost'),
'database' => env('DB_DATABASE', 'forge'),
'username' => env('DB_USERNAME', 'forge'),
'password' => env('DB_PASSWORD', ''),
'charset' => 'utf8',
'collation' => 'utf8_unicode_ci',
'prefix' => '',
'strict' => false,
],
Upvotes: 2