`

Rails2.2.2上安装mysql的adapter

    博客分类:
  • ROR
阅读更多

Rails2.2.2上gem install mysql

环境:WindowsXP RadRails ruby1.8.2 rails2.2.2 mysql5.1.30

 

google一下,发现Rails2.2.2库不包括mysql适配器,需要自己安装。

 

第一尝试,直接运行

 

gem install mysql

 发现公司网络有代理,无法远程安装,本地安装又没找到相应的gem库,只好接着试。

 

 

接着,尝试安装mysql的jdbc适配器。

先从http://gems.rubyforge.vm.bytemark.co.uk/gems/上下载

activerecord-jdbc-adapter-0.9.gem

jdbc-mysql-5.0.4.gem

activerecord-jdbcmysql-adapter-0.9.gem

 

运行

 

gem install E:\study\Ruby_on_Rails\ruby-gems\activerecord-jdbcmysql-adapter-0.9.gem
gem install E:\study\Ruby_on_Rails\ruby-gems\activerecord-jdbc-adapter-0.9.gem
gem install E:\study\Ruby_on_Rails\ruby-gems\jdbc-mysql-5.0.4.gem

 

安装信息

>gem install E:\study\Ruby_on_Rails\ruby-gems\jdbc-mysql-5.0.4.gem
Successfully installed jdbc-mysql-5.0.4
1 gem installed
Installing ri documentation for jdbc-mysql-5.0.4...
Installing RDoc documentation for jdbc-mysql-5.0.4...
>gem install E:\study\Ruby_on_Rails\ruby-gems\jdbc-mysql-5.0.4.gem
Successfully installed jdbc-mysql-5.0.4
1 gem installed
Installing ri documentation for jdbc-mysql-5.0.4...
Installing RDoc documentation for jdbc-mysql-5.0.4...
>gem install E:\study\Ruby_on_Rails\ruby-gems\activerecord-jdbcmysql-adapter-0.9.gem
Successfully installed activerecord-jdbcmysql-adapter-0.9
1 gem installed
Installing ri documentation for activerecord-jdbcmysql-adapter-0.9...
Installing RDoc documentation for activerecord-jdbcmysql-adapter-0.9...

 

运行

rake db:migrate

 

错误消息

>rake db:migrate
(in E:/workspace/studyRails)
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- mysql

(See full trace by running task with --trace)
>

 

根据提示,开启trace,运行

rake db:migrate --trace

 

>rake db:migrate --trace
rake db:migrate --trace
(in E:/workspace/studyRails)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.
rake aborted!
no such file to load -- jdbc-mysql-5.0.4/lib/jdbc/mysql.rb
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `gem_original_require'
C:/Ruby/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:31:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:521:in `new_constants_in'
C:/Ruby/lib/ruby/gems/1.8/gems/activesupport-2.2.2/lib/active_support/dependencies.rb:153:in `require'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:64:in `mysql_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `send'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:223:in `new_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:245:in `checkout_new_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:188:in `checkout'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `loop'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:184:in `checkout'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:183:in `checkout'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:98:in `connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_pool.rb:326:in `retrieve_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:121:in `retrieve_connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract/connection_specification.rb:113:in `connection'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:429:in `initialize'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:394:in `new'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:394:in `up'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/migration.rb:377:in `migrate'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:111
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
C:/Ruby/bin/rake:19:in `load'
C:/Ruby/bin/rake:19
>

 

注意这一行

C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:64:in `mysql_connection'

跟mysql配置有关系,根据进去,发现

# Require the MySQL driver and define Mysql::Result.all_hashes
      unless defined? Mysql
        begin
          require_library_or_gem('mysql')
        rescue LoadError
          $stderr.puts '!!! The bundled mysql.rb driver has been removed from Rails 2.2. Please install the mysql gem and try again: gem install mysql.'
          raise
        end
      end
      MysqlCompat.define_all_hashes_method!

 上面的

require_library_or_gem('mysql')

装载mysql.rb时失败。

 

接着,根据安装的mysql的jdbc适配器的目录修改mysql_adapter.rb中第63行

require_library_or_gem('mysql')

修改为

require 'jdbc/mysql'

继续运行

rake db:migrate --trace

出现错误信息 Mysql not loaded,至此好像进入死胡同。打开C:\Ruby\lib\ruby\gems\1.8\gems\jdbc-mysql-5.0.4\lib\jdbc\mysql.rb

module Jdbc
  module MySQL
    VERSION = "5.0.4"
  end
end
if RUBY_PLATFORM =~ /java/
  require "mysql-connector-java-#{Jdbc::MySQL::VERSION}-bin.jar"
else
  warn "jdbc-mysql is only for use with JRuby"
end

 mysql的JDBC适配器中的mysql.rb非常简单,清楚的表明

jdbc-mysql is only for use with JRuby

至此我发现自己一开始就错了,没有搞清楚环境就人云亦云的安装数据库适配器。(这也是网上一些文章的通病,对一些相关的东西交代不清楚,一不小心就着道了)

 

接着从http://gems.rubyforge.vm.bytemark.co.uk/gems/上下载了新的mysql适配器

addressable-2.0.2.gem

extlib-0.9.10.gem
data_objects-0.9.11.gem
do_mysql-0.9.11.gem

 

继续安装

gem install E:\study\Ruby_on_Rails\ruby-gems\addressable-2.0.2.gem
gem install E:\study\Ruby_on_Rails\ruby-gems\extlib-0.9.10.gem
gem install E:\study\Ruby_on_Rails\ruby-gems\data_objects-0.9.11.gem
gem install E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem

 

错误消息

>gem install E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem
ERROR:  http://gems.rubyforge.org/ does not appear to be a repository
ERROR:  Error installing E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem:
    do_mysql requires data_objects (= 0.9.11, runtime)
>gem install E:\study\Ruby_on_Rails\ruby-gems\data_objects-0.9.11.gem
ERROR:  http://gems.rubyforge.org/ does not appear to be a repository
ERROR:  Error installing E:\study\Ruby_on_Rails\ruby-gems\data_objects-0.9.11.gem:
    data_objects requires addressable (~> 2.0, runtime)
>gem install E:\study\Ruby_on_Rails\ruby-gems\addressable-2.0.2.gem
Successfully installed addressable-2.0.2
1 gem installed
Installing ri documentation for addressable-2.0.2...
Installing RDoc documentation for addressable-2.0.2...
>gem install E:\study\Ruby_on_Rails\ruby-gems\data_objects-0.9.11.gem
ERROR:  http://gems.rubyforge.org/ does not appear to be a repository
ERROR:  Error installing E:\study\Ruby_on_Rails\ruby-gems\data_objects-0.9.11.gem:
    data_objects requires extlib (~> 0.9.9, runtime)
>gem install E:\study\Ruby_on_Rails\ruby-gems\extlib-0.9.10.gem



>gem install E:\study\Ruby_on_Rails\ruby-gems\extlib-0.9.10.gem

Successfully installed extlib-0.9.10
1 gem installed
>gem install E:\study\Ruby_on_Rails\ruby-gems\data_objects-0.9.11.gem
ERROR:  http://gems.rubyforge.org/ does not appear to be a repository
Successfully installed data_objects-0.9.11
1 gem installed
Installing ri documentation for data_objects-0.9.11...
Installing RDoc documentation for data_objects-0.9.11...
>gem install E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem
ERROR:  http://gems.rubyforge.org/ does not appear to be a repository
Building native extensions.  This could take a while...
ERROR:  Error installing E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem:
    ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb install E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem
checking for mysql.h... no
checking for main() in libmysql.lib... no
checking for mysql_query() in mysql.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --srcdir=.
    --curdir
    --ruby=C:/Ruby/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-libmysqllib
    --without-libmysqllib


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/do_mysql-0.9.11 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/do_mysql-0.9.11/ext/do_mysql_ext/gem_make.out
>gem install E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem
ERROR:  http://gems.rubyforge.org/ does not appear to be a repository
Building native extensions.  This could take a while...
ERROR:  Error installing E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem:
    ERROR: Failed to build gem native extension.

C:/Ruby/bin/ruby.exe extconf.rb install E:\study\Ruby_on_Rails\ruby-gems\do_mysql-0.9.11.gem
checking for mysql.h... no
checking for main() in libmysql.lib... no
checking for mysql_query() in mysql.h... no
*** extconf.rb failed ***
Could not create Makefile due to some reason, probably lack of
necessary libraries and/or headers.  Check the mkmf.log file for more
details.  You may need configuration options.

Provided configuration options:
    --with-opt-dir
    --without-opt-dir
    --with-opt-include
    --without-opt-include=${opt-dir}/include
    --with-opt-lib
    --without-opt-lib=${opt-dir}/lib
    --with-make-prog
    --srcdir=.
    --curdir
    --ruby=C:/Ruby/bin/ruby
    --with-mysql-dir
    --without-mysql-dir
    --with-mysql-include
    --without-mysql-include=${mysql-dir}/include
    --with-mysql-lib
    --without-mysql-lib=${mysql-dir}/lib
    --with-libmysqllib
    --without-libmysqllib


Gem files will remain installed in C:/Ruby/lib/ruby/gems/1.8/gems/do_mysql-0.9.11 for inspection.
Results logged to C:/Ruby/lib/ruby/gems/1.8/gems/do_mysql-0.9.11/ext/do_mysql_ext/gem_make.out

 

 

在windows下安装do-mysql有点困难。

 

没办法,只好把电脑带回家,继续第一次尝试。这一次成功了,但是输出

 

>gem install mysql

Successfully installed mysql-2.7.3-x86-mswin32

1 gem installed

Installing ri documentation for mysql-2.7.3-x86-mswin32...

Installing RDoc documentation for mysql-2.7.3-x86-mswin32...

ERROR:  While generating documentation for mysql-2.7.3-x86-mswin32

... MESSAGE:   Unhandled special: Special: type=17, text="<!-- $Id: README.html,v 1.20 2006-12-20 05:31:52 tommy Exp $ -->"

... RDOC args: --op C:/Ruby/lib/ruby/gems/1.8/doc/mysql-2.7.3-x86-mswin32/rdoc --exclude ext --main README --quiet ext README docs/README.html

(continuing with the rest of the installation)

 

 

 

这表明库已经安装成功,但是rdoc安装失败了,不影响使用。

 

 

继续测试

 

script/generate scaffold article title:string article:text

 

 

exists app/models/

exists app/controllers/

exists app/helpers/

create app/views/articles

exists app/views/layouts/

exists test/functional/

exists test/unit/

exists public/stylesheets/

create app/views/articles/index.html.erb

create app/views/articles/show.html.erb

create app/views/articles/new.html.erb

create app/views/articles/edit.html.erb

create app/views/layouts/articles.html.erb

create public/stylesheets/scaffold.css

create app/controllers/articles_controller.rb

create test/functional/articles_controller_test.rb

create app/helpers/articles_helper.rb

route map.resources :articles

dependency model

exists app/models/

exists test/unit/

exists test/fixtures/

create app/models/article.rb

create test/unit/article_test.rb

create test/fixtures/articles.yml

create db/migrate

create db/migrate/20090225144729_create_articles.rb

 

 

 产生相应的骨架后,

 

rake db:migrate

 

 出错

 

>rake db:migrate 

(in E:/workspace/studyRails)

rake aborted!

Mysql::Error: Commands out of sync; you can't run this command now: SHOW TABLES

 

(See full trace by running task with --trace)

>

 

通过

gem list --local

 >gem list --local
actionmailer (2.2.2)
actionpack (2.2.2)
activerecord (2.2.2)
activerecord-jdbc-adapter (0.9)
activerecord-jdbcmysql-adapter (0.9)
activeresource (2.2.2)
activesupport (2.2.2)
addressable (2.0.2)
cgi_multipart_eof_fix (2.5.0)
data_objects (0.9.11)
extlib (0.9.10)
fxri (0.3.6)
fxruby (1.6.16)
gem_plugin (0.2.3)
hpricot (0.6.164)
jdbc-mysql (5.0.4)
linecache (0.43)
log4r (1.0.5)
mongrel (1.1.5)
mysql (2.7.3)
ptools (1.1.6)
rails (2.2.2)
rake (0.8.3, 0.8.1)
ruby-debug-base (0.10.3)
ruby-debug-ide (0.4.2)
ruby-opengl (0.60.0)
test-unit (2.0.1)
win32-api (1.2.1, 1.2.0)
win32-clipboard (0.4.4)
win32-dir (0.3.2)
win32-eventlog (0.5.0)
win32-file (0.5.5)
win32-file-stat (1.3.1)
win32-process (0.5.9)
win32-sapi (0.1.4)
win32-sound (0.4.1)
windows-api (0.2.4)
windows-pr (0.9.3)
>

 

发现mysql库的版本为2.7.3,猜测是不是mysql版本跟库不匹配造成? 

 

查询mysql的帮助文档

Commands out of sync in client错误

如果你在你的客户代码中得到Commands out of sync; You can't run this command now ,你正在以错误的次序调用客户函数!

这可能发生,例如,如果你正在使用mysql_use_result() 并且在你已经调用了mysql_free_result() 之前试图执行新查询。如果你在mysql_use_result()mysql_store_result() 之间试图执行返回数据的2个查询,它也可能发生。

 

 通过trace跟踪

rake db:migrate --trace

 

>rake db:migrate --trace
(in E:/workspace/studyRails)
** Invoke db:migrate (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute db:migrate
** Invoke db:schema:dump (first_time)
** Invoke environment
** Execute db:schema:dump
rake aborted!
Mysql::Error: Commands out of sync; you can't run this command now: SHOW TABLES
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/abstract_adapter.rb:188:in `log'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:309:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/connection_adapters/mysql_adapter.rb:414:in `tables'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/schema_dumper.rb:61:in `tables'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/schema_dumper.rb:23:in `dump'
C:/Ruby/lib/ruby/gems/1.8/gems/activerecord-2.2.2/lib/active_record/schema_dumper.rb:17:in `dump'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:246
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:245:in `open'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:245
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rails-2.2.2/lib/tasks/databases.rake:112
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `call'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:617:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:612:in `execute'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:578:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/1.8/monitor.rb:242:in `synchronize'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:571:in `invoke_with_call_chain'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:564:in `invoke'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2019:in `invoke_task'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `each'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1997:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1991:in `top_level'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1970:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:2036:in `standard_exception_handling'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/lib/rake.rb:1967:in `run'
C:/Ruby/lib/ruby/gems/1.8/gems/rake-0.8.3/bin/rake:31
C:/Ruby/bin/rake:19:in `load'
C:/Ruby/bin/rake:19
>

 

发现出错的地方位于mysql_adapter.rb:414,代码

    def tables(name = nil) #:nodoc:
        tables = []
        execute("SHOW TABLES", name).each { |field| tables << field[0] } #414行
        tables
      end

 

 为什么出这个错呢?猜测是mysql的库不匹配,先前把%MYSQL_HOME%/bin下的libmySQL.dll复制到%RUBY_HOME%/bin目录下,根据推测,用InstantRails-2.0-win.zip下的libmySQL.dll替换,再次跑db:migrate,果真一切ok。

 

真可谓一波三折矣!

分享到:
评论
1 楼 Anddy 2009-05-08  

相关推荐

Global site tag (gtag.js) - Google Analytics