Parallel Testing in Rails 6

If anyone is having trouble running parallel tests in their shiny new rails 6 applications and if you are getting the following error:

Error:
Mysql2::Error::ConnectionError: Access denied for user 'user'@'localhost' to database 'Users_test-0'

Error:
Mysql2::Error::ConnectionError: Access denied for user 'user'@'localhost' to database 'Users_test-1'

Please make sure the database user you are using to run the tests, ie. the user details given in the config/database.yml file for testing, MUST have ‘create database’ permission for the tests to run successfully since, the parallel tests in Rails 6 dynamically creates new databases per parallel test worker.

Doing the following helped me:

GRANT ALL PRIVILEGES ON * . * TO 'user'@'localhost' identified by 'password';

You can give the specific permission to the user to be more secure, but for development purposes the above should be enough.

Design a site like this with WordPress.com
Get started