2017-08-28 74 views
0

這裏是我的問題之一建立:TravisCI上的ActiveRecord的MySQL數據庫的正確連接字符串是什麼?

以下是錯誤:

Mysql2::Error: 
Access denied for user 'travis'@'%' 
to database 'rails_event_store_active_record' 

,這裏是連接字符串列表,我試圖

  • 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://[email protected]/rails_event_store_active_record?pool=5

這是我創建的DB:

before_script: 
    - mysql -e 'CREATE DATABASE rails_event_store_active_record;' 

並負責連接代碼:

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']) 

一切正常when I test my gem with Postgresql但它失敗爲Mysql。

https://docs.travis-ci.com/user/database-setup/#MySQL - 文件如何連接到MySQL數據庫,我不知道我現在做錯了什麼。

回答

1

我只是嘗試了一個選項,它的工作。顯然我不得不使用root用戶而不是travis,儘管文檔中提到了...

DATABASE_URL=mysql2://root:@127.0.0.1/rails_event_store_active_record?pool=5 
相關問題