mysql - Rails Mysql::错误:查询:未连接 Windows 7

标签 mysql ruby-on-rails ruby rubygems

我在 windows 7 上运行带 rails (3.0.7) 的 ruby​​ 1.9.2。设置 mysql gems 很困难,但最终发现在 windows7 上必须使用 mysql 适配器而不是 mysql2。 database.yml 看起来像这样:

    development:
      adapter: mysql
      encoding: utf8
      database: bfl
      pool: 5
      username: root
      password: 
      socket: /tmp/mysql.sock

“rails dbconsole development”命令工作正常(尽管它会重新提示我输入密码)。但是,我通过应用程序代码点击以下内容:

ActiveRecord::StatementInvalid (Mysql::Error: query: not connected: SELECT bfl_user.* FROM bfl_user)

我在其他平台上发现了几个类似的错误,但在 windows7 上没有发现,而且这些问题的来源不同。

最佳答案

我从ruby1.9.2切换到了ruby1.8.7。按照本教程使 mysql2 正常工作: http://rorguide.blogspot.com/2011/03/installing-mysql2-gem-on-ruby-192-and.html

在 1.9.2 中,注意到 mysql 连接有一个奇怪的挂起问题。

关于mysql - Rails Mysql::错误:查询:未连接 Windows 7,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7657819/

相关文章:

php - 从 php 数组简单更新 MySQl 表

ruby-on-rails - Rails 应用程序中全文 postgresql 搜索的奇怪行为

ruby-on-rails - 为 Prawn 中的某个单元格指定样式(特别是字体)

ruby - 替换所有其他字符

java - 如何从 JTable 获取值并添加到数据库。 Jtable 和 db 列不同

mysql - 符合增量同步条件的数据库模式

php - MySQL 使用 RegEx 更新/选择列

ruby-on-rails - 在使用Rails 3.1进行测试期间禁用终端中的SQL登录? (RSPEC/ cucumber )

ruby-on-rails - 如何覆盖自定义数据库适配器的 rake 任务?

ruby-on-rails - 在 rails 3 中使用 helpers 输出 html