Reputation: 1929
I'm developing a project in laravel and I have to change the db connection. I add a new connection and set this like default but when I run the app it uses the old connection and I don't understand why.
I'm not using .env
just setting config/database.php
.
'default' => env('DB_CONNECTION', 'DB2'),
'connections' => [
'DB2' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', 'IP'),
'database' => env('DB_DATABASE', 'DB2'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', '*****'),
'charset' => 'utf8',
'prefix' => '',
],
'DB1' => [
'driver' => 'sqlsrv',
'host' => env('DB_HOST', '127.0.0.1'),
'port' => env('DB_PORT', '2222'),
'database' => env('DB_DATABASE', 'DB1'),
'username' => env('DB_USERNAME', 'user'),
'password' => env('DB_PASSWORD', '****'),
'charset' => 'utf8',
'prefix' => '',
],
],
How can I solve this?
Thank you
Upvotes: 0
Views: 285
Reputation: 905
you just clear the config cache using the following commands:
php artisan config:clear
php artisan config:cache
Upvotes: 1