had the same problem and finally figured out that when accessing mysql5 via my particular host i also had to include the socket name.
so while this didn’t work for ‘DB_HOST’:
localhost
this did:
localhost:/tmp/mysql5.sock
hope this helps other users. the message that the db connection is working, but can’t find the database (when it clearly exists) is confusing!