Octobercms Can't Connect To DB; .env Is Fine And Php Artisan Tinker / Echo Env('DB_*') Outputs Correct Content

- 1 answer

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.

Any ideas?

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...