Rails 3无法使用mysql2 gem连接到远程数据库

时间:2011-05-09 05:32:06

标签: ruby-on-rails database ruby-on-rails-3 database-connection mysql2

  1. 我有2个环境:developmentdevelopment_with_production_data
  2. 环境仅在database.yml条目中有所不同:

    development:
      host: 127.0.0.1
      adapter: mysql2
      encoding: utf8
      database: [REDACTED]_development
      username: root
      password:
      pool: 5
    
    development_with_production_data:
      host: [REDACTED]
      port: [REDACTED]
      adapter: mysql2
      encoding: utf8
      database: [REDACTED]_production
      username: [REDACTED]
      password: [REDACTED]
      pool: 5
    
  3. 我已验证上面的[REDACTED]值是正确的值。我有一个可以很好地连接的gui和一个连接相同[REDACTED]值的rails 2应用程序。

  4. development环境中加载和处理工作非常完美,本地化。
  5. 加载和处理development_with_production_data环境除了静态缓存页面之外甚至都不会。没有错误消息,没有超时,没有。我所看到的就是:

    coneybeare $ rails s -e development_with_production_data
    NOTE: Gem::SourceIndex#all_gems is deprecated with no replacement. It will be removed on or after 2011-10-01.
    Gem::SourceIndex#all_gems called from /opt/local/lib/ruby/gems/1.8/gems/bundler-1.0.13/lib/bundler/rubygems_integration.rb:256
    .
    => Booting WEBrick
    => Rails 3.0.7 application starting in development_with_production_data on http://0.0.0.0:3000
    => Call with -d to detach
    => Ctrl-C to shutdown server
    [2011-05-09 01:23:48] INFO  WEBrick 1.3.1
    [2011-05-09 01:23:48] INFO  ruby 1.8.7 (2009-06-12) [i686-darwin10]
    [2011-05-09 01:23:48] INFO  WEBrick::HTTPServer#start: pid=3854 port=3000
    
  6. 我正在使用rails 3.0.7并尝试了mysql2 0.3.2mysql2 0.2.7

  7. 导致这种情况的原因是什么?

2 个答案:

答案 0 :(得分:1)

我终于通过使用RVM将我的ruby更新到我的mac上的1.9.2来解决这个问题。然后我不得不重新安装bundle gem,rails gem,并进行bundle安装。以前我一直在使用1.8.7,由于某种原因,它导致了挂起。

答案 1 :(得分:0)

尝试安装mysql2 0.2.x,因为rails 3.0.7中的mysql2 0.3.x存在一些问题

相关问题