Context :
I have DB1 and DB2 and a laravel application using DB1 so far
I want now that laravel (8) application to use DB2 instead (both DB1 & 2 are mysql)
I edited the .env file to change the DB_HOST and cleared the config cache
Expected : Laravel using DB2
Problem : Laravel still connects to DB1
Things I've tried :
php artisan config:cache
/ clearphp artisan optimize:clear
restarted DB1/DB2
restarted nginx
restarted php-fpm
redeployed the whole app (with composer install etc.)
tried adding a new connection in
config/database.php
instead of editing the existing one : same issuehardcoding the values in
config/database.php
instead of referencing the env file : same issuephp artisan db sql
--> connects to the RIGHT DB (this is what's driving me insane)... but php artisan tinker doesn't seem to. I created a dummy table in DB2 only (so not present in DB1) and getting that table with
\DB::connection('mysql')->table('dummy')->get();
shows an error via tinkerobviously, stopping DB1 makes the application go offline ("No such file or directory" blabla ie. no database PDO)
I don't even know what to try anymore. Every post somewhat related online are solved after a simple artisan config:clear/cache
....
Any thoughts appreciated ?
CodePudding user response:
The answer was DB_SOCKET=/tmp/mysql.sock
in my .env file that locked the connection to the previous (local) DB. Removing that from my env file solved the issue
CodePudding user response:
to change the database you need to write the database name on DB_DATABASE instead on DB_HOST...