Ruby on rails connection problem(Ruby on rails 连接问题)
问题描述
我有一个 Ruby on Rails 项目,我正在托管服务器上开发该项目,但已决定在我的本地 Windows 机器上工作.
I have a Ruby on Rails project that I was developing on a hosted server but have decided to work on my local windows machine with.
一开始我想我会确保我可以从旧项目中取出我的模型并将它们放在一个新项目中,然后在控制台中查询它们.这失败了.
To get started I thought I'd make sure that I could just take my models from the old project and put them in a new project then query them in the console. This fails.
编辑以反映更准确的问题:rails 为查询我的模型而建立的连接只能运行一个查询,然后为所有后续查询提供未连接"异常.有人知道这是怎么回事吗?我检查了我的配置,很多.如果 mysql 服务器上有一些我不知道的设置,我愿意查看.
Edit to reflect more accurate problem: The connection that rails builds to query my models can run only one query then gives the "Not connected" exception for all subsequent queries. Anybody know what's going on? I've checked my configuration, a lot. If there's some setting on mysql server that I don't know about I'd be willing to look at that.
堆栈跟踪:
Price.find(1)
ActiveRecord::StatementInvalid: Mysql::Error: query: not connected: SHOW FIELDS FROM `prices`
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/abstract_adapter.rb:212:in `log'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:320:in `execute'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/connection_adapters/mysql_adapter.rb:466:in `columns'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1271:in `columns'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1279:in `columns_hash'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1578:in `find_one'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:1569:in `find_from_ids'
from c:/Program Files/ruby/lib/ruby/gems/1.8/gems/activerecord-2.3.3/lib/active_record/base.rb:616:in `find'
from (irb):2
我已经确认我的 MySQL 数据库正在接受连接并且具有我期望的数据和结构.我已经仔细检查了我的连接等.有人能解释一下吗?
I've verified that my MySQL database is accepting connections and has the data and structure I expect. I've double checked my connections, etc. Can anyone shed some light?
推荐答案
我在 aptana 论坛.
那里说 MySQL 5.1 客户端库不能很好地与 Rails 2.2 配合使用他们提供的解决方案很简单:下载一个旧的 MySQL 客户端库 (libmySQL.dll) 并将其复制到您的 Rubyin 文件夹.
There it says that the MySQL 5.1 client library doesn't play well with Rails 2.2 The solution they offer is simple: download an older MySQL client library (libmySQL.dll) and copy it to your Rubyin folder.
这对我有用(Windows XP、Ruby 1.8.6、Rails 2.3.3、mysql 5.1.33)
This worked for me (Windows XP, Ruby 1.8.6, Rails 2.3.3, mysql 5.1.33)
这篇关于Ruby on rails 连接问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Ruby on rails 连接问题
- 导入具有可变标题的 Excel 文件 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01
- SQL 临时表问题 2022-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 在SQL中,如何为每个组选择前2行 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01