Reputation: 725
Here is one of my problematic builds:
Here is the error:
Mysql2::Error:
Access denied for user 'travis'@'%'
to database 'rails_event_store_active_record'
and here is a list of connection strings that I tried
DATABASE_URL=mysql2://travis:@127.0.0.1/rails_event_store_active_record?pool=5
DATABASE_URL=mysql2://[email protected]/rails_event_store_active_record?pool=5
DATABASE_URL=mysql2://travis@localhost/rails_event_store_active_record?pool=5
This is how I create the DB:
before_script:
- mysql -e 'CREATE DATABASE rails_event_store_active_record;'
And the code responsible for connecting:
ENV['DATABASE_URL'] ||= "postgres://localhost/rails_event_store_active_record?pool=5"
RSpec.configure do |config|
config.failure_color = :magenta
config.around(:each) do |example|
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
Everything works fine when I test my gem with Postgresql but it fails for Mysql.
https://docs.travis-ci.com/user/database-setup/#MySQL - documents how to connect to MySQL DB and I am not sure what I am doing wrong right now.
Upvotes: 0
Views: 569
Reputation: 725
I just tried one more option and it worked. Apparently I had to use root
user instead of travis
despite what the documentation says...
DATABASE_URL=mysql2://root:@127.0.0.1/rails_event_store_active_record?pool=5
Upvotes: 2