Laravel 5 app keeps using old database connection
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,
],
],
运行以下Artisan命令,然后重试:
php artisan cache:clear
php artisan config:clear
php artisan config:cache
php artisan route:clear
php artisan route:cache
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.
.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,
],
链接地址: http://www.djcxy.com/p/5650.html