我刚刚在我的 ubuntu 服务器上安装了乘客 (apache2) 以将我的 rails 3.1 rc4 rails 应用程序部署到野外,并想从 sqlite 更改为 mysql。
我安装了必要的 ubuntu 包
我用推荐的更新了我的 Gemfile:
gem 'mysql2'
并更新了我的 database.yml 文件
production:
adapter: mysql2
database: database
username: deploy
password: (***blocked for security reasons***)
socket: /var/run/mysqld/mysqld.sock
pool: 5
timeout: 5000
当我尝试使用 rake 创建生产数据库时:
rake db:migrate RAILS_ENV="production" --trace
它给了我一堆疯狂的错误
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
rake aborted!
”production” database is not configured
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord- 3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_specification.rb:62:in `establish_connection'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/connection_adapters/abstract/connection_specification.rb:55:in `establish_connection'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activerecord-3.1.0.rc4/lib/active_record/railtie.rb:69:in `block (2 levels) in <class:Railtie>'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc4/lib/active_support/lazy_load_hooks.rb:36:in `instance_eval'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc4/lib/active_support/lazy_load_hooks.rb:36:in `execute_hook'
/usr/local/rvm/gems/ruby-1.9.2-p180/gems/activesupport-3.1.0.rc4/lib/active_support/lazy_load_hooks.rb:26:in `on_load'
(And so on)
我试过安装常规的 mysql gem,但也没有用。我也尝试过<0.3 of mysql2,但这似乎导致了一个错误,抱怨使用rails 3.1 rc4版本0.2
我真的很难过:/