Octobercms Can't Connect To DB; .env Is Fine And Php Artisan Tinker / Echo Env('DB_*') Outputs Correct Content
I'm using OctoberCMS and, using the DB settings in the .env file I can connect to the DB without issue and I see a database named "mydatabase". BUT when I do
php artisan tinker and do
DB::connection()->getPdo(); I get the following:
InvalidArgumentException with message 'Database (mydatabase) does not exist.'
When I do
echo env('DB_HOST'); and
echo env('DB_PORT'); etc (for DB_DATABASE, DB_USERNAME and DB_PASSWORD) everything looks good. I can connect with those parameters with the mysql CLI command. And yet
DB::connection()->getPdo(); is failing.
I'm running OctoberCMS 1.0.443.
tail -f /path/to/myproject/storage/logs/system.log doesn't return anything (despite being writable)
Turns out I didn't have DB_DATABASE set in my .env. I had all the other DB_* values but not that one...
- → "failed to open stream" error when executing "migrate:make"
- → October CMS Plugin Routes.php not registering
- → OctoberCMS Migrate Table
- → OctoberCMS Rain User plugin not working or redirecting
- → October CMS Custom Mail Layout
- → October CMS - How to correctly route
- → October CMS create a multi select Form field
- → October CMS - Conditionally Load a Different Page
- → How to disable assets combining on development in OctoberCMS
- → October CMS - Radio Button Ajax Click Twice in a Row Causes Content to disappear
- → OctoberCms component: How to display all ID(items) instead of sorting only one ID?
- → In OctoberCMS how do you find the hint path?
- → How to register middlewares in OctoberCMS plugin?