我正在尝试使用带有ActiveRecord的ruby来访问mysql数据库。 ruby文件是dbtest.rb。
require 'rubygems'
require 'active_record'
ActiveRecord::Base.establish_connection(
:adapter => "mysql2",
:host => "localhost",
:database => "students"
)
class Rubyist < ActiveRecord::Base
end
当我尝试通过irb加载此文件或使用ruby运行它时,我收到以下错误:
.rvm/rubies/ruby-1.9.3-p194/lib/ruby/site_ruby/1.9.1/rubygems/custom_require.rb:55:in `require': Please install the mysql2 adapter: `gem install activerecord-mysql2-adapter`
我已经成功安装了mysql2 gem和activerecord-mysql2-adapter。当我安装activerecord-mysql2-adapter时,我收到了以下消息:
gem install activerecord-mysql2-adapter
Fetching: activerecord-mysql2-adapter-0.0.3.gem (100%)
Successfully installed activerecord-mysql2-adapter-0.0.3
1 gem installed
我是否需要重命名适配器?
答案 0 :(得分:1)
我将“export DYLD_LIBRARY_PATH = / usr / local / mysql / lib:$ DYLD_LIBRARY_PATH”添加到修复它的.bash_profile。