rails test attempts to create multiple test databases and fails because it cannot connect
I'm having (what seems to me) a rather peculiar problem running rails test right from the get-go. All the correct databases exist, the rails user has what should be all the required privileges, and I've run db:migrate. Rather than using the app test database, it will try to create numbered versions of it and use those. The error I get is like:
Mysql2::Error::ConnectionError: Access denied for user 'rails_remote'@'%' to database 'sample_app_test-3'
Naturally, this fails, because the rails user does not have the CREATE privilege. Even with it, the rails user does not have any privileges on the newly created databases, so it fails again.
How do I get rails to use the existing test database rather than trying to create its own?
ETA: It seems to be associated with the following line in test_helper.rb. Comment it out and things seem to work as expected.
Well, I learned about Parallel Testing today, a new "feature" of Rails 6. Kinda cool, but probably shouldn't be a default of newly created applications.
It also means that you need to give your mysql user privileges on databases that match a pattern:
grant all privileges on `sample_app_test-%`.* to 'my_user'@'%';