【问题标题】:Rails 3 not able to connect to remote DB with mysql2 gemRails 3 无法使用 mysql2 gem 连接到远程数据库
【发布时间】:2011-08-21 10:23:54
【问题描述】:
  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

这可能是什么原因造成的?

【问题讨论】:

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


    【解决方案1】:

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

    【讨论】:

      【解决方案2】:

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

      【讨论】:

      • 谢谢,我也尝试过(应该提到它)但发生了同样的问题。宝石'mysql2','
      • 哦,我明白了..Rails 有时会抛出未知的 WTF :)
      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2015-12-03
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-12-19
      • 2019-10-16
      相关资源
      最近更新 更多