也有多种情况罗列到一起吧
# MySQL. Versions 4.1 and 5.0 are recommended.
#
# Install the MySQL driver:
# gem install mysql
# On Mac OS X:
# sudo gem install mysql -- --with-mysql-dir=/usr/local/mysql
# On Mac OS X Leopard:
# sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-config=/usr/local/mysql/bin/mysql_config
sudo env ARCHFLAGS="-arch i386" gem install mysql -- --with-mysql-dir=/usr/local/mysql --with-mysql-lib=/usr/local/mysql/lib --with-mysql-include=/usr/local/mysql/include
一下为linux情况
You may face some issues while configuring rails;
引用
no such file to load — mysql
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `gem_original_require’
/usr/lib/ruby/site_ruby/1.8/rubygems/custom_require.rb:27:in `require’
/usr/lib/ruby/gems/1.8/gems/activesupport-2.3.2/lib/active_support/dependencies.rb:156:in `require’
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:65:in `mysql_connection’
and so on
step 1:
If you havn’t done “
gem install mysql
”; do it first.
step 2:
引用
If it doesn’t work even after “gem install mysql”; search for “mysql.so” in your system. In linux box; the path would be something like;
‘/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.so’
step 3:
In the error message; you will see the error file(mysql_adapter.rb); In my case it is [check error sample above];
引用
/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb:65:in `mysql_connection’
step 4:
Open the file “/usr/lib/ruby/gems/1.8/gems/activerecord-2.3.2/lib/active_record/connection_adapters/mysql_adapter.rb” and go to location 65.
You will find a line something like;
require_library_or_gem(’mysql’)
change this line to look like;
require_library_or_gem(’/usr/local/lib/ruby/gems/1.8/gems/mysql-2.7/mysql.so’)
再不行参考如下
http://www.ruby-forum.com/topic/192550